Bug in the urljoin library

2020-04-28 Thread Moro, Andrea via Python-list
x27;http:', url) Input: domain.tld/somepath Output http:///domain.tld/somepath -- *Andrea Moro* SEO Specialist – Digital Marketer e: i...@andreamoro.eu w: http://www.andreamoro.eu Questo messaggio di posta elettronica può contenere informazioni riservate o privilegi legali ed è destinat

Re: Python, Be Bold!

2020-01-05 Thread Andrea D'Amore
On Thu, 2 Jan 2020 at 09:38, Chris Angelico wrote: > The wheel does not need to be reinvented. I see what you did there. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Jupyter Notebook -> PDF with A4 pages?

2019-11-01 Thread Andrea D'Amore
mmand "pip" to be resolved by the shell. , try calling the absolute path /usr/bin/pip . I do keep pip updated in the user directory with on Ubuntu with no issue. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: (New to Python) Shopping List Code

2019-10-28 Thread Andrea D'Amore
-1: Try these two in REPL and see how the break condition you are using in your code is evaluated, then check each of the comparison operands. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: what's the differences: None and null?

2019-09-15 Thread Andrea D'Amore
ame of the null object. [1]: https://docs.python.org/3/library/stdtypes.html?highlight=null#the-null-object -- Andrea On Sat, 14 Sep 2019 at 03:40, Random832 wrote: > > On Fri, Sep 13, 2019, at 21:22, Hongyi Zhao wrote: > > what's the differences: None and null? > > nul

Re: issue in handling CSV data

2019-09-08 Thread Andrea D'Amore
not clear what format do you expect to be in the file. You say "it is CSV" so your actual payload seems to be a pair of three bytes (a tab and two hex digits in ASCII) per line. Can you paste a hexdump of the first three lines of the input file and say what you expect to get once

Re: How do I decouple these two modules?

2019-08-28 Thread Andrea D'Amore
On Wed, 28 Aug 2019 at 10:04, Spencer Du via Python-list wrote: > I have code for a GUI and MQTT […] currently they rely on each other to some > extent. How? I am failing to see the circular dependency there. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Mergesort problem

2016-12-22 Thread Andrea D'Amore
ders's "Loop like a native" talk about that, there are both a webpage and a PyCon talk. By using "native" looping you'll get simplified code that is more expressive in less lines. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me cythonize a python routine!

2016-11-09 Thread Andrea D'Amore
On 10 November 2016 at 00:15, Steve D'Aprano wrote: > py> import collections […] > py> import os > py> os.listdir('/usr/local/lib/python3.5/collections/') Not os.listdir(collections.__path__[0]) since it's already there? -- Andrea -- https://m

Re: Lua tutorial help for Python programmer?

2016-11-08 Thread Andrea D'Amore
s is pretty trivial stuff, mostly representing > things which are just above the level of the simplest tutorial. Check "Programming in Lua" book, older versions are made available online by the author. [1]: http://lua-users.org/wiki/TutorialDirectory -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: advanced SimpleHTTPServer?

2016-11-02 Thread Andrea D'Amore
On 2 November 2016 at 08:27, Ulli Horlacher wrote: > "python -m SimpleHTTPServer" is really cool :-) > - some kind of a chroot, to prevent file access higher then the base > directory Shouldn't that be done by chrooting the python process in the calling environment

Re: Need help with coding a function in Python

2016-11-01 Thread Andrea D'Amore
re since the sequence conditional rule depends on it. Any hints on how to make it better are welcome. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Software Needs Philosophers

2016-09-12 Thread Andrea D'Amore
On 2016-09-12 17:09:03 +, danut...@gmail.com said: Yes, it does: Operating systems do as well <https://en.wikipedia.org/wiki/Dining_philosophers_problem>. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: How to split value where is comma ?

2016-09-11 Thread Andrea D'Amore
your message. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Python source repo

2016-09-11 Thread Andrea D'Amore
nd I found a few but I figure one has to know some hg internal in order to inspect where it hung up. Btw I experienced similar, sporadic issues with hg in past, I had the impression those were network-related, not reproducible on my side anyway. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Recursive csv import functions for Pandas

2016-08-02 Thread andrea . botti
I have put together the following code: ## DEFINES INPUT FILES inputcsvT = ['./input_csv/A08_KI_T*.csv', './input_csv/A08_LR_T*.csv','./input_csv/A08_B1_T*.csv',] #'./input_csv/A10_KI_T*.csv', './input_csv/A10_LR_T*.csv',

Re: Compiling extensions on Python 2.7, Windows 10 64 bit

2016-04-30 Thread Andrea Gavana
Hi, On Friday, 29 April 2016, Igor Korot wrote: > Andrea, > > On Fri, Apr 29, 2016 at 4:27 PM, Andrea Gavana > wrote: > > Hi, > > > > > > On Friday, 29 April 2016, Igor Korot > > wrote: > >> > >> Andrea, > >&

Re: Compiling extensions on Python 2.7, Windows 10 64 bit

2016-04-29 Thread Andrea Gavana
Hi, On Friday, 29 April 2016, Igor Korot wrote: > Andrea, > > On Fri, Apr 29, 2016 at 3:45 PM, > > wrote: > > Dear list, > > > > I have been trying to compile wxPython Phoenix ( > https://github.com/wxWidgets/Phoenix) from source on Windows 10 64 bit,

Compiling extensions on Python 2.7, Windows 10 64 bit

2016-04-29 Thread andrea . gavana
on what to try next. Does anyone have suggestions/comments on where I should look for/what I should do/what I should change in order to get the extension running on Python 2.7? Thank you in advance for your suggestions :-) . Andrea. -- https://mail.python.org/mailman/listinfo/python-list

Issues with to run python

2016-02-06 Thread Dánisa Andrea Alejo García
. Danisa Andrea Alejo Northeastern University Cellphone number: 617-431-0280 -- https://mail.python.org/mailman/listinfo/python-list

Re: Issues with to run python

2016-02-06 Thread Dánisa Andrea Alejo García
Sent from my iPhone On Feb 6, 2016, at 3:10 PM, Dánisa Andrea Alejo García mailto:alejo...@hotmail.com>> wrote: Dear Technician, I am writing to you because I have downloaded Python,I have followed all the instructions, but for some reason I am unable to use it. I am sending to

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-18 Thread andrea . gavana
onds. Not a bad improvement :-) . Unfortunately, when the file is on a network drive, all the other approaches ran at around 25-30 seconds loading time, while the mmap one clocks at 110 seconds :-( Andrea. -- https://mail.python.org/mailman/listinfo/python-list

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Peter, On Tuesday, November 17, 2015 at 4:57:57 PM UTC+1, Peter Otten wrote: > Andrea Gavana wrote: > > > Hi Chris, > > > > On Tuesday, November 17, 2015 at 4:20:34 PM UTC+1, Chris Angelico wrote: > >> On Wed, Nov 18, 2015 at 1:20 AM, Andrea Gavana wrote: &g

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Chris, On Tuesday, November 17, 2015 at 4:20:34 PM UTC+1, Chris Angelico wrote: > On Wed, Nov 18, 2015 at 1:20 AM, Andrea Gavana wrote: > > Thank you for your answer. I do get similar timings when I swap the two > > functions, and specifically still 15 seconds to re

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Peter, On Tuesday, November 17, 2015 at 3:14:57 PM UTC+1, Peter Otten wrote: > Andrea Gavana wrote: > > > Hello List, > > > > I am working with relatively humongous binary files (created via > > cPickle), and I stumbled across some u

cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
n one go (somehow) into a string ready for cPickle.loads without that much of an overhead? Note that all of this has been done on Windows 7 64bit with Python 2.7 64bit, with 16 cores and 100 GB RAM (so memory should not be a problem). Thank you in advance for all suggestions :-) . Andrea. #

Re: Help with Debugging

2015-09-27 Thread Andrea D'Amore
he pastebin, did you possibly copy text from web thus pasting smartquotes or unprintables in your source file? -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about python package numpy

2015-03-01 Thread Andrea D'Amore
tandemqueue.py" with link to the file, why don't you get the source files for the example from their pages? [1] http://wiki.scipy.org/Cookbook/Solving_Large_Markov_Chains -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Andrea D'Amore
On 2014-12-02 17:41:06 +, Zachary Ware said: foo == 42 or else Never going to happen, but I like it! Perhaps raise IntimidationError instead of AssertionError when it fails? That should probably be a DONTPANICError in large, friendly terminal font letters. -- Andrea -- https

Re: Idle on Mac issues

2014-11-04 Thread Andrea D'Amore
ightly outdated 2.7.6 as that's the one shipped with the system and it's better not to tinker with it, IIRC there are system scripts relying on it. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Idle on Mac issues

2014-11-04 Thread Andrea D'Amore
pport. I can start the idle binary provided by all of those, the system's with native GUI, and have working Options menu in all of them. I'd suggest the people having issue to describe their issues here, with details on the system version, python version, the exact command they run

Re: brackets at the end of a method name

2014-09-24 Thread Andrea D'Amore
On 2014-09-24 13:30:55 +, ast said: we have some methods associated with file f […] f.close() f.name print(type(f.close)) print(type(f.name)) Spot the difference. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: find the error

2014-09-12 Thread Andrea D'Amore
On 2014-09-13 05:53:37 +, Chris Angelico said: If you're using sys.argv, you need to provide arguments to your script. Or check sys.argv's length ensuring that an element is there before accessing it. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Psycopg2 package installation puzzle in Pycharm - any thoughts?

2014-09-01 Thread Andrea D'Amore
rself with a tool that provides us with some context" add nothing and are not exactly community inclusive. Still you took the time to write the message I'm replying to, that won't help you much, rather than running """ import sys print(sys.executable) "&quo

Re: Psycopg2 package installation puzzle in Pycharm - any thoughts?

2014-09-01 Thread Andrea D'Amore
You make hard to follow your messages both by sending lot of messages and not using an adequate quoting. Please pick a posting style [1] (possibly interleaved) and stick to it. On 2014-08-31 23:35:09 +, andydtay...@gmail.com said: Andrea - yes I am using the virtualenv interpreter as the

Re: Psycopg2 package installation puzzle in Pycharm - any thoughts?

2014-08-31 Thread Andrea D'Amore
On 2014-08-31 14:19:24 +, andydtay...@gmail.com said: - Installing to a virtualenv python environment. Are you using the virtualenv interpreter as the Pycharm project interpreter? -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Network/multi-user program

2014-07-22 Thread Andrea D'Amore
oa it's pretty straightforward to use. [1] http://dabodev.com/ [2] http://www.cappuccino-project.org/ -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 on Mac OS X 10.8.4

2014-06-19 Thread Andrea D'Amore
is to install and learn to use a package manager, I use MacPorts that requires full Xcode. Brew should require the smaller command line package. Fink should require no additional packages since it's basically APT. There are other managers as well, these are the most common on OS X. -- Andrea

Re: Da dove prende python il default timezone?

2014-06-06 Thread Andrea D'Amore
heezy, server in USA, EU timezone) and my strftime works as expected: ~> cat /etc/timezone Europe/Rome ~> date "+%H" 20 ~> python -c 'import time; print time.strftime("%H")' 20 Try reconfiguring tzdata package again. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-04 Thread Andrea D'Amore
On 2014-06-03 20:43:06 +, Sturla Molden said: I see no reason to use Swift instead of Python and PyObjC Most likely there'll be better integration with Xcode and its tools. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: IDE for python

2014-05-30 Thread Andrea D'Amore
On 2014-05-30 07:21:52 +, Andrea D'Amore said: It aims at providing a beautiful interface, Side note: the text editing is still green. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: IDE for python

2014-05-30 Thread Andrea D'Amore
so far is impressively neat. I'm not related to the project, I just found it by accident and want to give Cocoa-credit where credit is due. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: How to implement key of key in python?

2014-05-10 Thread Andrea D'Amore
lists. The term "combined" hasn't a specific pythonic meaning there and is just used as a meaningful variable name as the author is combining, i.e. adding, numerical values. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: Installing PyGame?

2014-04-26 Thread Andrea D'Amore
couldn't figure what the OP actually did, he says "just about every way possible", or what his "an error" actually is. Most likely all those methods are good, I'd rather fix any of those by providing further info than switch to another one looking for a magical so

Re: Installing PyGame?

2014-04-26 Thread Andrea D'Amore
nce the more libraries/software I install the more useful a package manager becomes in terms of stray files left when upgrading or uninstalling. I use a mix of MacPorts to provide the base tools and virtualenv for project-specific pypi libraries. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] Usage of U+00B6 PILCROW SIGN (was: generator slides review and Python doc (+/- text bug))

2014-02-04 Thread andrea crotti
2014-02-04 : > Le mardi 4 février 2014 15:39:54 UTC+1, Jerry Hill a écrit : > > Useless and really ugly. > I think this whole discussion is rather useless instead, why do you care since you're not going to use this tool anyway? -- https://mail.python.org/mailman/listinfo/python-list

Re: generator slides review

2014-02-03 Thread andrea crotti
2014-02-03 Terry Reedy : > On 2/2/2014 5:40 AM, andrea crotti wrote: >> > In general, use assert (== AssertionError) to check program logic (should > never raise). Remember that assert can be optimized away. Use other > exceptions to check user behavior. So I believe

Re: generator slides review and Python doc (+/- text bug)

2014-02-03 Thread andrea crotti
2014-02-03 : > generator slides review and Python doc > > > I do not know what tool is used to produce such > slides. > > When the mouse is over a a text like a title ( ... <\H*> ???) > the text get transformed and a colored eol is appearing. > > Example with the slide #3: > > Even numbers > becom

Re: generator slides review

2014-02-02 Thread andrea crotti
Thanks everyone for your feedback. The talk I think went well, maybe I was too fast because I only used 21 minutes. >From the audience feedback, there were some questions about my "Buggy code" example, so yes probably it's not a good example since it's too artificial. I'll have to find something

Re: generator slides review

2014-02-02 Thread andrea crotti
which explain things, to tell a clear story in a way 2014-02-02 andrea crotti : > The slides are updated now > > 2014-02-02 andrea crotti : >> 2014-02-01 Miki Tebeka : >>> >>> My 2 cents: >>> >>> slide 4: >>> [i*2 for i in range(10)]

Re: generator slides review

2014-02-02 Thread andrea crotti
The slides are updated now 2014-02-02 andrea crotti : > 2014-02-01 Miki Tebeka : >> >> My 2 cents: >> >> slide 4: >> [i*2 for i in range(10)] >> > > Well this is not correct in theory because the end should be the max > number, not the number of e

Re: generator slides review

2014-02-02 Thread andrea crotti
2014-02-01 Miki Tebeka : > > My 2 cents: > > slide 4: > [i*2 for i in range(10)] > Well this is not correct in theory because the end should be the max number, not the number of elements. So it should be [i*2 for i in range(10/2)] which might be fine but it's not really more clear imho.. > slide

Re: generator slides review

2014-02-02 Thread andrea crotti
2014-02-02 Terry Reedy : > On 2/1/2014 9:12 AM, andrea crotti wrote: > > Comments: > > The use is assert in the first slide seem bad in a couple of different > respects. > Why is it bad? It's probably not necessary but since we ask for a range it might be good to c

generator slides review

2014-02-01 Thread andrea crotti
I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables.. The slides are here (forgive the strange Chinese characters): https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3 and the code I'm using is: https://github.com/AndreaCrotti/generators/blob/master/code/

Re: how to avoid spaghetti in Python?

2014-01-21 Thread andrea crotti
2014/1/21 CM : > I've been learning and using Python for a number of years now but never > really go particularly disciplined about all good coding practices. I've > definitely learned *some*, but I'm hoping this year to take a good step up in > terms of refactoring, maintainability, and mostly

Re: lxml tostring quoting too much

2013-08-07 Thread andrea crotti
2013/8/6 Chris Down : > On 2013-08-06 18:38, andrea crotti wrote: >> I would really like to do the following: >> >> from lxml import etree as ET >> from lxml.builder import E >> >> url = "http://something?x=10&y=20"; >> l = E

lxml tostring quoting too much

2013-08-06 Thread andrea crotti
I would really like to do the following: from lxml import etree as ET from lxml.builder import E url = "http://something?x=10&y=20"; l = E.link(url) ET.tostring(l) -> "http://something?x=10&y=20" However the lxml tostring always quotes the &, I can't find a way to tell it to avoid quoting it. Is

Re: decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
2013/6/18 Terry Reedy > On 6/18/2013 5:47 AM, andrea crotti wrote: > >> Using a CouchDB server we have a different database object potentially >> for every request. >> >> We already set that db in the request object to make it easy to pass it >> around form

Re: decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
2013/6/18 Wolfgang Maier > andrea crotti gmail.com> writes: > > > > > > > Using a CouchDB server we have a different database object potentially > for > every request. > > > > We already set that db in the request object to make it easy to pass it &

Re: python-django for dynamic web survey?

2013-06-18 Thread andrea crotti
Django makes your life a lot easier in many ways, but you still need some time to learn it. The task you're trying it's not trivial though, depending on your experience it might take a while with any library/framework.. -- http://mail.python.org/mailman/listinfo/python-list

decorator to fetch arguments from global objects

2013-06-18 Thread andrea crotti
Using a CouchDB server we have a different database object potentially for every request. We already set that db in the request object to make it easy to pass it around form our django app, however it would be nice if I could set it once in the API and automatically fetch it from there. Basically

Re: Getting a callable for any value?

2013-05-29 Thread andrea crotti
On 05/29/2013 06:46 PM, Croepha wrote: Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return "%s.%s(%r)" % (self.__class__.__module__, self.__class__

pip and different branches?

2013-05-20 Thread andrea crotti
We use github and we work on many different branches at the same time. The problem is that we have >5 repos now, and for each repo we might have the same branches on all of them. Now we use pip and install requirements such as: git+ssh://g...@github.com/repo.git@dev Now the problem is that the r

Re: dynamic forms generation

2013-04-19 Thread andrea crotti
Well I think since we are using django anyway (and bottle on the API side) I'm not sure why we would use flask forms for this.. Anyway the main question is probably, is it worth to try to define a DSL or not? The problem I see is that we have a lot and very complex requirements, trying to define a

dynamic forms generation

2013-04-16 Thread andrea crotti
We are re-designing a part of our codebase, which should in short be able to generate forms with custom fields. We use django for the frontend and bottle for the backend (using CouchDB as database), and at the moment we simply plug extra fields on normal django forms. This is not really scalable,

Re: Mixin way?

2013-04-03 Thread andrea crotti
2013/4/3 Steven D'Aprano > [snip] > > So, if you think of "Visitable" as a gadget that can be strapped onto > your MyObj as a component, then composition is probably a better design. > But if you think of "Visitable" as a mere collection of behaviour and > state, then a mixin is probably a better

Mixin way?

2013-04-03 Thread andrea crotti
I have some classes that have shared behaviours, for example in our scenario an object can be "visited", where something that is visitable would have some behaviour like --8<---cut here---start->8--- class Visitable(Mixin): FIELDS = { 'visits': [],

Re: groupby behaviour

2013-02-26 Thread andrea crotti
2013/2/26 Ian Kelly : > On Tue, Feb 26, 2013 at 9:27 AM, andrea crotti > wrote: >> So I was trying to use groupby (which I used in the past), but I >> noticed a very strange thing if using list on >> the result: > > As stated in the docs: > > ""&qu

Re: running multiple django/bottle instances

2013-01-07 Thread andrea crotti
che, your problem > is actually not Python related. > If you want to run your applications on different ports, take a look on e.g. > Apaches virtual host configurations. > http://httpd.apache.org/docs/2.2/vhosts/examples.html > > Am 03.01.2013 17:35, schrieb Andrea Crotti: > &

running multiple django/bottle instances

2013-01-03 Thread Andrea Crotti
I'm working on a quite complex web app that uses django and bottle (bottle for the API which is also restful). Before I came they started to use a staging server to be able to try out things properly before they get published, but now we would like to have the possibility to see multiple branches

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 Dennis Lee Bieber : > On Tue, 11 Dec 2012 10:34:23 -0300, peter declaimed > the following in gmane.comp.python.general: > >> >> stderrfile = '%s/error.log' % os.getcwd() >> stdoutfile = '%s/out.log' % os.getcwd() >> > Ouch... > > stdoutfile = os.path.join(os.getcwd(), "o

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 Jean-Michel Pichavant : > - Original Message - >> So I implemented a simple decorator to run a function in a forked >> process, as below. >> >> It works well but the problem is that the childs end up as zombies on >> one machine, while strangely >> I can't reproduce the same on m

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
2012/12/11 peter : > On 12/11/2012 10:25 AM, andrea crotti wrote: >> >> Ah sure that makes sense! >> >> But actually why do I need to move away from the current directory of >> the parent process? >> In my case it's actually useful to be in the same

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
Ah sure that makes sense! But actually why do I need to move away from the current directory of the parent process? In my case it's actually useful to be in the same directory, so maybe I can skip that part, or otherwise I need another chdir after.. -- http://mail.python.org/mailman/listinfo/pyth

Re: forking and avoiding zombies!

2012-12-11 Thread andrea crotti
leno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno()) if __name__ == '__main__': daemonize(stdout='sample_file', stderr='sample') print("hello world, now should be the child!") [andrea@andreacrotti experiments]$ python2 daemon.py Traceback (

Re: creating size-limited tar files

2012-11-14 Thread Andrea Crotti
On 11/14/2012 04:33 PM, Dave Angel wrote: Well, as I said, I don't see how the particular timing has anything to do with the rest of the thread. If you want to do an ls within a Python program, go ahead. But if all you need can be done with ls itself, then it'll be slower to launch python just

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Dave Angel : > On 11/14/2012 10:56 AM, andrea crotti wrote: >> Ok this is all very nice, but: >> >> [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py > /dev/null >> >> real 0m21.215s >> user 0m0.750s >> sys 0m1.703s >>

Re: creating size-limited tar files

2012-11-14 Thread andrea crotti
2012/11/14 Kushal Kumaran : > > Well, well, I was wrong, clearly. I wonder if this is fixable. > > -- > regards, > kushal > -- > http://mail.python.org/mailman/listinfo/python-list But would it not be possible to use the pipe in memory in theory? That would be way faster and since I have in theor

Re: creating size-limited tar files

2012-11-08 Thread andrea crotti
2012/11/8 andrea crotti : > > > > Yes yes I saw the answer, but now I was thinking that what I need is > simply this: > tar czpvf - /path/to/archive | split -d -b 100M - tardisk > > since it should run only on Linux it's probably way easier, my script > will then

Re: creating size-limited tar files

2012-11-08 Thread andrea crotti
2012/11/7 Oscar Benjamin : > > Correct. But if you read the rest of Alexander's post you'll find a > suggestion that would work in this case and that can guarantee to give > files of the desired size. > > You just need to define your own class that implements a write() > method and then distributes

Re: creating size-limited tar files

2012-11-07 Thread Andrea Crotti
On 11/07/2012 08:32 PM, Roy Smith wrote: In article <509ab0fa$0$6636$9b4e6...@newsspool2.arcor-online.net>, Alexander Blinne wrote: I don't know the best way to find the current size, I only have a general remark. This solution is not so good if you have to impose a hard limit on the resulti

Re: accepting file path or file object?

2012-11-05 Thread andrea crotti
2012/11/5 Peter Otten <__pete...@web.de>: > I sometimes do something like this: > > $ cat xopen.py > import re > import sys > from contextlib import contextmanager > > @contextmanager > def xopen(file=None, mode="r"): > if hasattr(file, "read"): > yield file > elif file == "-": >

lazy properties?

2012-11-01 Thread Andrea Crotti
Seeing the wonderful "lazy val" in Scala I thought that I should try to get the following also in Python. The problem is that I often have this pattern in my code: class Sample: def __init__(self): self._var = None @property def var(self): if self._var is None:

Re: Nice solution wanted: Hide internal interfaces

2012-10-30 Thread andrea crotti
2012/10/30 alex23 : > On Oct 30, 2:33 am, Johannes Bauer wrote: >> I'm currently looking for a good solution to the following problem: I >> have two classes A and B, which interact with each other and which >> interact with the user. Instances of B are always created by A. >> >> Now I want A to ca

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread andrea crotti
2012/10/29 Johannes Bauer : > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to call some private methods of B

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Chris Angelico : > On Tue, Oct 30, 2012 at 2:55 AM, Paul Rubin wrote: >> andrea crotti writes: >>> and we want to change its state incrementing the number ... >>> the immutability purists would instead suggest to do this: >>> def increment(

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > > In an OOP language num.increment() is expected to modify the object in place. > So I think you're right when you say that functional languages technics do > not necessarily apply to Python, because they don't. > > I would add that what you're trying to sugg

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 andrea crotti : >> > > Well sure but it doesn't modify the first object, just creates a new > one. There are in general good reasons to do that, for example I can > then compose things nicely: > > num.increment().increment() > > or I can parallelize

Re: Immutability and Python

2012-10-29 Thread andrea crotti
2012/10/29 Jean-Michel Pichavant : > > "return NumWrapper(self.number + 1) " > > still returns a(nother) mutable object. > > So what's the point of all this ? > > JM > Well sure but it doesn't modify the first object, just creates a new one. There are in general good reasons to do that, for examp

Re: resume execution after catching with an excepthook?

2012-10-25 Thread andrea crotti
2012/10/25 Steven D'Aprano : > On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: > >> So I would like to be able to ask for confirmation when I receive a C-c, >> and continue if the answer is "N/n". > > I don't think there is any way to do thi

resume execution after catching with an excepthook?

2012-10-24 Thread andrea crotti
So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is "N/n". I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in any case.. A possible solution would be to do

Re: locking files on Linux

2012-10-19 Thread andrea crotti
2012/10/18 Oscar Benjamin : > > The lock is cooperative. It does not prevent the file from being > opened or overwritten. It only prevents any other process from > obtaining the lock. Here you open the file with mode 'w' which > truncates the file instantly (without checking for the lock). > > > Os

Re: Testing against multiple versions of Python

2012-10-19 Thread andrea crotti
2012/10/19 Michele Simionato : > Yesterday I released a new version of the decorator module. It should run > under Python 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3. I did not have the will > to install on my machine 8 different versions of Python, so I just tested it > with Python 2.7 and 3.3. But

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Oscar Benjamin : > > Why not come up with a test that actually shows you if it works? Here > are two suggestions: > > 1) Use time.sleep() so that you know how long the lock is held for. > 2) Write different data into the file from each process and see what > you end up with. > Ok thank

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Grant Edwards : > On 2012-10-18, andrea crotti wrote: > > > File locks under Unix have historically been "advisory". That means > that programs have to _choose_ to pay attention to them. Most > programs do not. > > Linux does support mandatory lock

Re: Generating C++ code

2012-10-10 Thread andrea crotti
2012/10/10 Jean-Michel Pichavant : > Well, the C++ code will end up running on a MIPS on a SOC, unfortunately, > python is not an option here. > The xml to C++ makes a lot of sense, because only a small part of the code is > generated that way (everything related to log & fatal events). Everythin

Re: Generating C++ code

2012-10-09 Thread Andrea Crotti
On 10/09/2012 05:00 PM, Jean-Michel Pichavant wrote: Greetings, I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. My google search about this subject has been quite unsuccessful, I've been redirected to t

Re: PHP vs. Python

2012-09-25 Thread andrea crotti
2012/9/25 : > On Thursday, 23 December 2004 03:33:36 UTC+5:30, (unknown) wrote: >> Anyone know which is faster? I'm a PHP programmer but considering >> getting into Python ... did searches on Google but didn't turn much up >> on this. >> >> Thanks! >> Stephen > > > Here some helpful gudance. > >

Re: Python presentations

2012-09-24 Thread andrea crotti
For anyone interested, I already moved the slides on github (https://github.com/AndreaCrotti/pyconuk2012_slides) and for example the decorator slides will be generated from this: https://raw.github.com/AndreaCrotti/pyconuk2012_slides/master/deco_context/deco.rst Notice the literalinclude with :py

Re: 'str' object does not support item assignment

2012-09-23 Thread Andrea Crotti
On 09/23/2012 07:31 PM, jimbo1qaz wrote: spots[y][x]=mark fails with a "'str' object does not support item assignment" error,even though: a=[["a"]] a[0][0]="b" and: a=[["a"]] a[0][0]=100 both work. Spots is a nested list created as a copy of another list. But a = "a" a[0] = 'c' fails f

  1   2   3   4   5   6   >