[issue39387] configparser read_file() with variable

2020-01-19 Thread Mattia Verga
Mattia Verga added the comment: I started trying to reproduce this with different Python interpreters and I've found it now works as expected also with the original one (BTW it was CPython 3.7.6). I really don't know why it didn't work before. Sorry for the noise. -- resolution

[issue39387] configparser read_file() with variable

2020-01-19 Thread Mattia Verga
New submission from Mattia Verga : I'm trying to assign a file object to a variable and then pass this variable to configparse.read_file(), but for some reason that doesn't work: >>> import configparser >>> config = configparser.ConfigParser() >>> config.read_

[issue36180] mboxMessage.get_payload throws TypeError on malformed content type

2019-03-04 Thread Mattia Rizzolo
Change by Mattia Rizzolo : -- nosy: +mapreri ___ Python tracker <https://bugs.python.org/issue36180> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue30150] raw debug allocators to not return malloc alignment

2017-04-24 Thread Mattia Rizzolo
Changes by Mattia Rizzolo <mat...@mapreri.org>: -- nosy: +mapreri ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30150> ___ __

Web page special characters encoding

2010-07-10 Thread mattia
Hi all, I'm using py3k and the urllib package to download web pages. Can you suggest me a package that can translate reserved characters in html like egrave;, ograve;, eacute; in the corresponding correct encoding? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: Web page special characters encoding

2010-07-10 Thread mattia
Il Sat, 10 Jul 2010 18:09:12 +0100, MRAB ha scritto: mattia wrote: Hi all, I'm using py3k and the urllib package to download web pages. Can you suggest me a package that can translate reserved characters in html like egrave;, ograve;, eacute; in the corresponding correct encoding? import

Re: Web page special characters encoding

2010-07-10 Thread mattia
Il Sat, 10 Jul 2010 16:24:23 +, mattia ha scritto: Hi all, I'm using py3k and the urllib package to download web pages. Can you suggest me a package that can translate reserved characters in html like egrave;, ograve;, eacute; in the corresponding correct encoding? Thanks, Mattia

Re: Join a thread and get the return value of a function

2009-12-25 Thread mattia
Il Fri, 25 Dec 2009 05:19:46 +1100, Lie Ryan ha scritto: import threading class MyThread(threading.Thread): def join(self): super(MyThread, self).join() return self.result class Worker(MyThread): def run(self): total = 0 for i in

Join a thread and get the return value of a function

2009-12-24 Thread mattia
Hi all, is there a way in python to get back the value of the function passed to a thread once the thread is finished? Something like pthread_join() in C? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: Join a thread and get the return value of a function

2009-12-24 Thread mattia
Il Fri, 25 Dec 2009 00:35:55 +1100, Lie Ryan ha scritto: On 12/25/2009 12:23 AM, mattia wrote: Hi all, is there a way in python to get back the value of the function passed to a thread once the thread is finished? Something like pthread_join() in C? Thanks, Mattia use a Queue to pass

dict initialization

2009-12-22 Thread mattia
Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? -- http://mail.python.org/mailman/listinfo/python-list

Re: dict initialization

2009-12-22 Thread mattia
Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? There is a dictionary variant that you don't have to initialize: from

Re: dict initialization

2009-12-22 Thread mattia
Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? There is a dictionary variant that you don't have to initialize: from

console command to get the path of a function

2009-12-20 Thread mattia
Hi all, is there a way in the python shell to list the path of a library function (in order to look at the source code?). Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: py itertools?

2009-12-20 Thread mattia
Il Sun, 20 Dec 2009 03:49:35 -0800, Chris Rebert ha scritto: On Dec 19, 12:48 pm, Chris Rebert c...@rebertia.com wrote: On Sat, Dec 19, 2009 at 2:54 AM, mattia ger...@gmail.com wrote: Hi all, I need to create the permutation of two strings but without repeat the values, e.g. 'ab' for me

Re: console command to get the path of a function

2009-12-20 Thread mattia
Il Sun, 20 Dec 2009 13:53:18 +0100, Irmen de Jong ha scritto: On 12/20/2009 1:45 PM, mattia wrote: Hi all, is there a way in the python shell to list the path of a library function (in order to look at the source code?). Thanks, Mattia something like this? import inspect import os

Re: console command to get the path of a function

2009-12-20 Thread mattia
Il Sun, 20 Dec 2009 13:53:18 +0100, Irmen de Jong ha scritto: On 12/20/2009 1:45 PM, mattia wrote: Hi all, is there a way in the python shell to list the path of a library function (in order to look at the source code?). Thanks, Mattia something like this? import inspect import os

Re: Sort the values of a dict

2009-12-19 Thread mattia
Il Sat, 19 Dec 2009 17:30:27 +1100, Lie Ryan ha scritto: On 12/19/2009 9:34 AM, mattia wrote: Can you provide me a much pythonic solution (with comments if possible, so I can actually learn something)? If you only need to get i'th element sometimes, sorting the dict is fine. Otherwise, you

py itertools?

2009-12-19 Thread mattia
, a % b) ... def mcm(a, b): ... return int((a * b) / mcd(a, b)) ... s1 = 'abc' s2 = 'wt' m = mcm(len(s1), len(s2)) set(zip(s1*m, s2*m)) {('a', 'w'), ('a', 't'), ('b', 'w'), ('c', 't'), ('b', 't'), ('c', 'w')} Any help? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: py itertools?

2009-12-19 Thread mattia
Il Sat, 19 Dec 2009 10:54:58 +, mattia ha scritto: Hi all, I need to create the permutation of two strings but without repeat the values, e.g. 'ab' for me is equal to 'ba'. Here is my solution, but maybe the python library provides something better: def mcd(a, b): ... if b == 0

Sort the values of a dict

2009-12-18 Thread mattia
... res = [] for x in pres: ... res.append((x, d[x])) ... res [(2, ('u', 9, 8)), (5, ('r', 21, 10)), (1, ('a', 1, 12))] Can you provide me a much pythonic solution (with comments if possible, so I can actually learn something)? Thanks, Mattia -- http://mail.python.org/mailman/listinfo

Re: Sort the values of a dict

2009-12-18 Thread mattia
Actually, in order to use duplicate values I need something like: import copy d = {1:('a', 1, 12), 5:('r', 21, 10), 2:('u', 9, 8), 3:('u', 9, 8) } dc = copy.deepcopy(d) t = [x for x in d.values()] def third(mls): ... return mls[2] ... s = sorted(t, key=third) pres = [] for x in s: ...

Re: Sort the values of a dict

2009-12-18 Thread mattia
Il Fri, 18 Dec 2009 18:00:42 -0500, David Robinow ha scritto: On Fri, Dec 18, 2009 at 5:34 PM, mattia ger...@gmail.com wrote: Hi all, I have a dictionary that uses dates and a tuples ad key, value pairs. I need to sort the values of the dict and insert everything in a tuple. The additional

Re: insert unique data in a list

2009-12-14 Thread mattia
Il Sun, 13 Dec 2009 21:17:28 -0800, knifenomad ha scritto: On 12월14일, 오후12시42분, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Dec 2009 17:19:17 -0800, knifenomad wrote: this makes the set type hashable. class Set(set):     __hash__ = lambda self: id(self)

print format

2009-12-14 Thread mattia
Hi all, I wanto to print just the first 5 characters of a string, why this doesn't work (py3.1)? print({0:5}.format(123456789)) 123456789 I know I could use print(123456789[:5]), yeah it's a stupid example, but isn't format for string formatting? Thanks, Mattia -- http://mail.python.org

Re: insert unique data in a list

2009-12-14 Thread mattia
Il Mon, 14 Dec 2009 21:53:38 +, Steven D'Aprano ha scritto: On Mon, 14 Dec 2009 17:13:24 +, mattia wrote: Il Sun, 13 Dec 2009 21:17:28 -0800, knifenomad ha scritto: On 12월14일, 오후12시42분, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Dec 2009 17:19:17

insert unique data in a list

2009-12-13 Thread mattia
How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val) Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: insert unique data in a list

2009-12-13 Thread mattia
Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val) Thanks

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: On Dec 9, 11:53 pm, mattia ger...@gmail.com wrote: Hi all, can you provide me a simple code snippet to interrupt

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Thu, 10 Dec 2009 23:10:02 +, Matthew Barnett ha scritto: mattia wrote: Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: On Dec 9, 11:53 pm, mattia ger

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: On Dec 9, 11:53 pm, mattia ger...@gmail.com wrote: Hi all, can you provide me a simple code snippet to interrupt the execution of my program catching the KeyboardInterrupt signal? Thanks, Mattia Errr, normally you can just

Re: Working threads progress

2009-10-31 Thread mattia
Il Wed, 28 Oct 2009 20:04:45 -0700, ryles ha scritto: On Oct 28, 7:02 pm, mattia ger...@gmail.com wrote: Now, I would like to know the activity done (e.g. every two seconds) so I create another thread that checks the queue size (using .qsize()). Have you any suggestion to improve the code

Working threads progress

2009-10-28 Thread mattia
hi all, I have a simple program that uses multiple threads to carry out some work. Every threads share the same queue.Queue() (that is synchronized) in order to get some data and then carry out the work. Suppose I have something like: q = queue.Queue() for x in range(100): q.put(x) then I

Re: print()

2009-10-18 Thread mattia
Il Sat, 17 Oct 2009 10:38:55 -0400, Dave Angel ha scritto: mattia wrote: Il Fri, 16 Oct 2009 22:40:34 -0700, Dennis Lee Bieber ha scritto: On Fri, 16 Oct 2009 23:39:38 -0400, Dave Angel da...@ieee.org declaimed the following in gmane.comp.python.general: You're presumably testing

Re: print()

2009-10-18 Thread mattia
Il Sat, 17 Oct 2009 10:02:27 -0400, Dave Angel ha scritto: mattia wrote: Il Fri, 16 Oct 2009 21:04:08 +, mattia ha scritto: Is there a way to print to an unbuffered output (like stdout)? I've seen that something like sys.stdout.write(hello) works but it also prints the number

Re: print()

2009-10-18 Thread mattia
Il Sun, 18 Oct 2009 20:04:11 -0200, Gabriel Genellina ha scritto: En Sun, 18 Oct 2009 10:35:34 -0200, mattia ger...@gmail.com escribió: Il Sat, 17 Oct 2009 10:02:27 -0400, Dave Angel ha scritto: mattia wrote: Il Fri, 16 Oct 2009 21:04:08 +, mattia ha scritto: Another question (always

Re: print()

2009-10-17 Thread mattia
Il Fri, 16 Oct 2009 22:40:34 -0700, Dennis Lee Bieber ha scritto: On Fri, 16 Oct 2009 23:39:38 -0400, Dave Angel da...@ieee.org declaimed the following in gmane.comp.python.general: You're presumably testing this in the interpreter, which prints extra stuff. In particular, it prints the

Re: putchar(8)

2009-10-17 Thread mattia
Il Sat, 17 Oct 2009 06:48:10 -0400, Dave Angel ha scritto: Dave Angel wrote: Jason Tackaberry wrote: On Fri, 2009-10-16 at 12:01 -0700, gervaz wrote: Hi all, is there in python the equivalent of the C function int putchar (int c)? I need to print putchar(8). print '\x08'

print()

2009-10-16 Thread mattia
Is there a way to print to an unbuffered output (like stdout)? I've seen that something like sys.stdout.write(hello) works but it also prints the number of characters! -- http://mail.python.org/mailman/listinfo/python-list

() vs []

2009-10-15 Thread mattia
Any particular difference in using for a simple collection of element () over [] or vice-versa? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Download and save a picture - urllib

2009-09-11 Thread mattia
Hi all, in order to download an image. In order to correctly retrieve the image I need to set the referer and handle cookies. opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler (), urllib.request.HTTPCookieProcessor()) urllib.request.install_opener(opener) req =

Re: Download and save a picture - urllib

2009-09-10 Thread mattia
You were right, the problem was with the print function, using a normal write everythong works fine. Il Thu, 10 Sep 2009 18:56:07 +0200, Diez B. Roggisch ha scritto: mattia wrote: Hi all, in order to download an image. In order to correctly retrieve the image I need to set the referer

lxml question

2009-09-09 Thread mattia
, 'mobile'); alt=sms src=images/button_sms.bmp id=smsToMobile name=smsToMobile/ I don't know how to do it (I'm trying using lxml, but any suggestion can help). Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Screenshot of a web page

2009-04-29 Thread mattia
Are you aware of any python module that automatically gives you a screenshot of a web page? -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dict and iter

2009-04-02 Thread mattia
Il Thu, 02 Apr 2009 13:44:38 +, Sion Arrowsmith ha scritto: mattia ger...@gmail.com wrote: So, I'm looking for a way to reset the next() value every time i complete the scan of a list. itertools.cycle ? Perfect, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Help with dict and iter

2009-03-29 Thread mattia
you suggest me a more python way? Ciao, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dict and iter

2009-03-29 Thread mattia
Il Sun, 29 Mar 2009 11:17:50 -0400, andrew cooke ha scritto: mattia wrote: Hi all, I a list of jobs and each job has to be processed in a particular order by a list of machines. A simple representation is: # Ordering of machines JOB1 = [3, 1, 2, 4] JOB2 = [2, 3, 1, 4] JOBS = [JOB1, JOB2

Re: Help with dict and iter

2009-03-29 Thread mattia
Il Sun, 29 Mar 2009 12:00:38 -0400, andrew cooke ha scritto: mattia wrote: [i wrote]: don't you just want to have a new job machine? for job_list in job_list_list: job_machine = dict((x+1, iter(JOBS[x])) for x in range(NJOBS)) for x in job_list: print(next(job_machine[x])) ok

Code anntotations (copyright, autor, etc) in your code

2009-03-26 Thread mattia
Hi all, which are the usual comments that you put at the beginning of your code to explain e.g. the author, the usage, the license etc? I've found useful someting like: #- # Name:About.py # Purpose: # # Author:

Generator

2009-03-22 Thread mattia
Can you explain me this behaviour: s = [1,2,3,4,5] g = (x for x in s) next(g) 1 s [1, 2, 3, 4, 5] del s[0] s [2, 3, 4, 5] next(g) 3 Why next(g) doesn't give me 2? -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator

2009-03-22 Thread mattia
Il Sun, 22 Mar 2009 16:52:02 +, R. David Murray ha scritto: mattia ger...@gmail.com wrote: Can you explain me this behaviour: s = [1,2,3,4,5] g = (x for x in s) next(g) 1 s [1, 2, 3, 4, 5] del s[0] s [2, 3, 4, 5] next(g) 3 Why next(g) doesn't give me 2? Think

Re: Roulette wheel

2009-03-19 Thread mattia
Il Wed, 18 Mar 2009 23:31:09 -0200, Gabriel Genellina ha scritto: En Wed, 18 Mar 2009 18:49:19 -0200, mattia ger...@gmail.com escribió: Il Wed, 18 Mar 2009 13:20:14 -0700, Aahz ha scritto: In article 49c1562a$0$1115$4fafb...@reader1.news.tin.it, mattia ger...@gmail.com wrote: Yeah, and I

Simple question about yyyy/mm/dd

2009-03-19 Thread mattia
Hi all, I need to receive in input a date represented by a string in the form /mm/dd (or reversed), then I need to assure that the date is = the current date and then split the dates in variables like year, month, day. Is there some module to do this quickly? --

Re: Roulette wheel

2009-03-18 Thread mattia
Il Wed, 18 Mar 2009 09:34:57 -0700, Aahz ha scritto: In article gop0se$7hu$0...@news.t-online.com, Peter Otten __pete...@web.de wrote: mattia wrote: cpop += [nchromosome1] + [nchromosome2] I'd write that as cpop.append(nchromosome1) cpop.append(nchromosome2) thus avoiding

Re: Roulette wheel

2009-03-18 Thread mattia
Il Wed, 18 Mar 2009 13:20:14 -0700, Aahz ha scritto: In article 49c1562a$0$1115$4fafb...@reader1.news.tin.it, mattia ger...@gmail.com wrote: Yeah, and I believe that we can say the same for: 1 - t = [x*2 for x in range(10)] 2 - t = list(x*2 for x in range(10)) or not? The latter requires

urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread mattia
Hi all, can you tell me why the module urllib.request (py3) add extra characters (b'fef\r\n and \r\n0\r\n\r\n') in a simple example like the following and urllib2 (py2.6) correctly not? py2.6 import urllib2 f = urllib2.urlopen(http://www.google.com;).read() fd = open(google26.html, w)

Re: Lists aggregation

2009-03-17 Thread mattia
Il Tue, 17 Mar 2009 08:18:08 +0100, Peter Otten ha scritto: Mensanator wrote: On Mar 16, 1:40 pm, Peter Otten __pete...@web.de wrote: mattia wrote: I have 2 lists, like: l1 = [1,2,3] l2 = [4,5] now I want to obtain a this new list: l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5

Re: urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread mattia
Il Tue, 17 Mar 2009 10:55:21 +, R. David Murray ha scritto: mattia ger...@gmail.com wrote: Hi all, can you tell me why the module urllib.request (py3) add extra characters (b'fef\r\n and \r\n0\r\n\r\n') in a simple example like the following and urllib2 (py2.6) correctly not? py2.6

Re: urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread mattia
Il Tue, 17 Mar 2009 10:55:21 +, R. David Murray ha scritto: mattia ger...@gmail.com wrote: Hi all, can you tell me why the module urllib.request (py3) add extra characters (b'fef\r\n and \r\n0\r\n\r\n') in a simple example like the following and urllib2 (py2.6) correctly not? py2.6

Re: urllib2 (py2.6) vs urllib.request (py3)

2009-03-17 Thread mattia
Il Tue, 17 Mar 2009 15:40:02 +, R. David Murray ha scritto: mattia ger...@gmail.com wrote: Il Tue, 17 Mar 2009 10:55:21 +, R. David Murray ha scritto: mattia ger...@gmail.com wrote: Hi all, can you tell me why the module urllib.request (py3) add extra characters (b'fef\r\n

Lists aggregation

2009-03-16 Thread mattia
wanted to use the zip function, but the new list will not aggregate (3,4) and (3,5) - Once I've the new list, I'll apply a map function (e.g. the exp of the values) to speed up the process Some help? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: String to sequence

2009-03-15 Thread mattia
Il Sat, 14 Mar 2009 15:30:29 -0500, Tim Chase ha scritto: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',

List the moduels of a package

2009-03-15 Thread mattia
Hi all, how can I list the modules provided by a package? -- http://mail.python.org/mailman/listinfo/python-list

Set overlapping

2009-03-15 Thread mattia
How can I determine the common values found in two differents sets and then assign this values? E.g. dayset = [Mon, Tue, Wed, Thu, Fri, Sat, Sun] monthset = [Jan, Feb, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] this are the fixed and standard sets. Then I have others sets that contains one

Correct URL encoding

2009-03-15 Thread mattia
I'm using urlopen in order to download some web pages. I've always to replace some characters that are in the url, so I've come up with: url.replace(|, %7C).replace(/, %2F).replace( , +).replace (:, %3A) There isn't a better way of doing this? --

Re: Correct URL encoding

2009-03-15 Thread mattia
Il Sun, 15 Mar 2009 17:05:16 -0700, Chris Rebert ha scritto: On Sun, Mar 15, 2009 at 4:54 PM, gervaz ger...@gmail.com wrote: On Mar 16, 12:38 am, Graham Breed x3...@cnntp.org wrote: mattia wrote: I'm using urlopen in order to download some web pages. I've always to replace some characters

String to sequence

2009-03-14 Thread mattia
How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] Thanks a lot, Mattia -- http://mail.python.org/mailman

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:24:38 +0100, Ulrich Eckhardt ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:35:59 +0100, Peter Otten ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 12:13:31 +0100, Peter Otten ha scritto: mattia wrote: Il Sat, 14 Mar 2009 10:35:59 +0100, Peter Otten ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ

Re: Is there a better way of doing this?

2009-03-07 Thread mattia
Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto: En Fri, 06 Mar 2009 21:31:01 -0200, mattia ger...@gmail.com escribió: Thanks, I've found another solution here: http://www.obitko.com/tutorials/ genetic-algorithms/selection.php so here is my implementation: def get_fap

Is there a better way of doing this?

2009-03-06 Thread mattia
Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def get_fitness_and_population(fitness, population): return [(fitness(x), x) for x in population] def selection(fitness, population): ''' Select the parent chromosomes from a

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 10:19:22 +, mattia ha scritto: Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def get_fitness_and_population(fitness, population): return [(fitness(x), x) for x in population] def selection(fitness

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto: On Fri, Mar 6, 2009 at 3:07 AM, mattia ger...@gmail.com wrote: Great, the for statement has not to deal with fap anymore, but with another sequence, like this: def get_roulette_wheel(weight_value_pairs):    roulette_wheel

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto: mattia wrote: Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def get_fitness_and_population(fitness, population): return [(fitness(x), x) for x in population] def

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 22:28:00 +0100, Peter Otten ha scritto: mattia wrote: Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto: mattia wrote: Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def get_fitness_and_population

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 18:46:44 -0300, andrew cooke ha scritto: i have not been following this discussion in detail, so someone may have already explained this, but it should not be necessary to actually construct the roulette wheel to select values from it. what you are doing is selecting from

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 14:13:47 -0800, Scott David Daniels ha scritto: mattia wrote: Here is my last shot, where I get rid of all the old intermediate functions: def selection(fitness, population): lp = len(population) roulette_wheel = [] for x in population

Re: Roulette wheel

2009-03-05 Thread mattia
Il Thu, 05 Mar 2009 10:46:58 +0100, Peter Otten ha scritto: mattia wrote: Note how get_roulette_wheel() is now completeley independent of the concrete problem you are using it for. Ok, but also a lot more memory consuming ;-) I don't think so. Python references objects; therefore

Re: Roulette wheel

2009-03-05 Thread mattia
Il Thu, 05 Mar 2009 12:54:39 +0100, Peter Otten ha scritto: mattia wrote: Il Thu, 05 Mar 2009 10:46:58 +0100, Peter Otten ha scritto: mattia wrote: Note how get_roulette_wheel() is now completeley independent of the concrete problem you are using it for. Ok, but also a lot more

Re: Roulette wheel

2009-03-05 Thread mattia
Il Wed, 04 Mar 2009 21:30:54 +0100, Peter Otten ha scritto: mattia wrote: Hi everyone, I'm new to python and I want to create some simple code in order to code the classical genetic algorithm example: given a population of chromosomes, encoded using 1 and 0, find the chromosome

Re: Roulette wheel

2009-03-05 Thread mattia
Il Thu, 05 Mar 2009 15:48:01 +, mattia ha scritto: Il Wed, 04 Mar 2009 21:30:54 +0100, Peter Otten ha scritto: mattia wrote: Hi everyone, I'm new to python and I want to create some simple code in order to code the classical genetic algorithm example: given a population

Re: Roulette wheel

2009-03-05 Thread mattia
for a, b in zip(*[iter(pop)]*2): In the python documentation there is a similar example, well, the obscure thing here is the usage of *[iter(pop)]! Then I believe that I can safely say that you iterate over the values 0 and 1, 2 and 3 etc. because the zip automatically updates the index,

Re: Roulette wheel

2009-03-05 Thread mattia
Il Thu, 05 Mar 2009 18:07:29 +0100, Peter Otten ha scritto: mattia wrote: The last question: how can I improve readability in this piece of code? def crossover(pop, prob=0.6): With a crossover probability cross over the parents to form new offspring. If no crossover

Roulette wheel

2009-03-04 Thread mattia
Hi everyone, I'm new to python and I want to create some simple code in order to code the classical genetic algorithm example: given a population of chromosomes, encoded using 1 and 0, find the chromosome with the maximum number of 1s. Now, despite all the code used to implement the solution,

Re: Roulette wheel

2009-03-04 Thread mattia
Il Wed, 04 Mar 2009 21:30:54 +0100, Peter Otten ha scritto: mattia wrote: Hi everyone, I'm new to python and I want to create some simple code in order to code the classical genetic algorithm example: given a population of chromosomes, encoded using 1 and 0, find the chromosome

Re: Roulette wheel

2009-03-04 Thread mattia
Note how get_roulette_wheel() is now completeley independent of the concrete problem you are using it for. Ok, but also a lot more memory consuming ;-) -- http://mail.python.org/mailman/listinfo/python-list

Library similar to UserAgent (perl)

2009-02-12 Thread mattia
Hi everybody, I'm looking for an easy way to put data in a form, then click the button and follow the redirect. Also I need to use cookies. I read that using perl this can be done using the UserAgent lib, that also provide th browser functionality to let the site believe that you are getting

Re: Library similar to UserAgent (perl)

2009-02-12 Thread mattia
Il Thu, 12 Feb 2009 13:47:09 +0100, Diez B. Roggisch ha scritto: mattia wrote: Hi everybody, I'm looking for an easy way to put data in a form, then click the button and follow the redirect. Also I need to use cookies. I read that using perl this can be done using the UserAgent lib

Re: just a bug

2007-05-25 Thread Mattia Gentilini
that. -- |\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo) |/_| ETICS project at CNAF, INFN, Bologna, Italy |\/| www.getfirefox.com www.getthunderbird.com * Using Mac OS X 10.4.9 powered by Cerebros (Core 2 Duo) * -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in python with regular expressions

2007-05-25 Thread Mattia Gentilini
Thorsten Kampe ha scritto: I'm trying to parsing html with re module. Just don't. Use an HTML parser like BeautifulSoup Or HTMLParser/htmllib -- |\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo) |/_| ETICS project at CNAF, INFN, Bologna, Italy |\/| www.getfirefox.com

Re: How to do this in python with regular expressions

2007-05-25 Thread Mattia Gentilini
Thorsten Kampe ha scritto: I'm trying to parsing html with re module. Just don't. Use an HTML parser like BeautifulSoup Or HTMLParser/htmllib. of course you can mix those and re, it'll be easier than re only. -- |\/|55: Mattia Gentilini e 55 = log2(che_palle_sta_storia) (by mezzo) |/_| ETICS

Re: Python on Vista installation issues

2007-05-23 Thread Mattia Gentilini
will ha scritto: Vista is a 64 bit OS and there is no port of pywin32 for either Vista or 64-bit XP Vista exists in BOTH 32 bit and 64 bit versions. -- |\/|55: Mattia Gentilini e 55 curve di seguito con gli sci |/_| ETICS project at CNAF, INFN, Bologna, Italy |\/| www.getfirefox.com

Re: 32 OS on 64-bit machine

2007-05-03 Thread Mattia Gentilini (CNAF)
~/Desktop/ETICS]$ python Python 2.3.5 (#1, Aug 19 2006, 21:31:42) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type help, copyright, credits or license for more information. import platform print platform.processor() i386 print platform.architecture() ('32bit', '') -- Mattia

security

2005-10-25 Thread Mattia Adami
Hi to all. I'm intristing in write a plugin for browsers that can execute python code. I know the main problem is security. Many thread were opened about this in the ng. I would know if fork python rewriting some library could avoid problems. I.e. one problem is the possibility to access files. If

c/c++ and python

2005-09-29 Thread Mattia Adami
Hi to all! I have a little problem. I want to develop an application in c/c++ that creates a window with gtk+ accordinly to the information on a xml file. The funcions that are called for manage the event should be written in python. I don't know how to do it, can you help me? Is it possible?

Re: c/c++ and python

2005-09-29 Thread Mattia Adami
Thanks a lot, very clear and usefull anser! Yes, I know PyGTK and wxPython, but I want to develop a plugin for another application that requires c++. I guess that embedding is the appropriate way. Thanks. -- http://mail.python.org/mailman/listinfo/python-list