Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Paul Rubin
Steven Truppe writes: > # here i would like to create a directory named after the content of > # the title... I allways get this error: > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2 The title has a à (capital A with tilde) character in it, and there is no corresponding

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
Thanks, ChrisA On Tue, Nov 22, 2016 at 9:24 PM, Chris Angelico wrote: > On Wed, Nov 23, 2016 at 2:14 PM, Nathan Ernst > wrote: > > I was not aware of that PEP. > > > > The logic in my function is exactly as desired, so to squelch the > warning, > > I merely wrapped the iteration in a try/except

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Chris Angelico
On Wed, Nov 23, 2016 at 2:14 PM, Nathan Ernst wrote: > I was not aware of that PEP. > > The logic in my function is exactly as desired, so to squelch the warning, > I merely wrapped the iteration in a try/except: > > def adjacent_difference(seq, selector=identity): > i = iter(seq) > l = select

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Chris Angelico
On Wed, Nov 23, 2016 at 1:50 PM, Nathan Ernst wrote: > I'm using Python 3.5.2, and the following code (when invoked) causes a > PendingDeprecationWarning when used in a unit test: > > def identity(x): > return x > > def adjacent_difference(seq, selector=identity): > i = iter(seq) > l = selec

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
Thanks, I was not aware of that PEP. The logic in my function is exactly as desired, so to squelch the warning, I merely wrapped the iteration in a try/except: def adjacent_difference(seq, selector=identity): i = iter(seq) l = selector(next(i)) try: while True: r = selector(next(

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread MRAB
On 2016-11-23 02:50, Nathan Ernst wrote: I'm using Python 3.5.2, and the following code (when invoked) causes a PendingDeprecationWarning when used in a unit test: def identity(x): return x def adjacent_difference(seq, selector=identity): i = iter(seq) l = selector(next(i)) while True:

Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
I'm using Python 3.5.2, and the following code (when invoked) causes a PendingDeprecationWarning when used in a unit test: def identity(x): return x def adjacent_difference(seq, selector=identity): i = iter(seq) l = selector(next(i)) while True: r = selector(next(i)) yield r - l

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Steve D'Aprano
On Wed, 23 Nov 2016 09:00 am, Lew Pitcher wrote: > 2) Apparently os.mkdir() (at least) defaults to requiring an ASCII > pathname. No, you have misinterpreted what you have seen. Even in Python 2, os.mkdir will accept a Unicode argument. You just have to make sure it is given as unicode: os.mkd

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Steve D'Aprano
On Wed, 23 Nov 2016 07:54 am, Steven Truppe wrote: > I've made a pastebin with a few examples: http://pastebin.com/QQQFhkRg Your pastebin appears to be the same code as you've shown here. And, again, it doesn't seem to be the actual code you are really running. The only new or helpful informatio

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Steve D'Aprano
On Wed, 23 Nov 2016 07:33 am, Steven Truppe wrote: > imort chardet That's not working Python code. Steven, you have asked us to help you with some code. For us to do that, we need to see the ACTUAL code you are running, not some other code which is full of typos and may be very different from wh

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Lew Pitcher
On Tuesday November 22 2016 15:54, in comp.lang.python, "Steven Truppe" wrote: > I've made a pastebin with a few examples: http://pastebin.com/QQQFhkRg > > > > On 2016-11-22 21:33, Steven Truppe wrote: >> I all, >> >> >> i'm using linux and python 2 and want to parse a file line by line by >>

new python package: financial_life

2016-11-22 Thread Martin Pyka
Hi folks, for all data scientists and especially financial analysts out there, this python package might be a useful resource: https://github.com/MartinPyka/financial_life With financial_life, monetary flows between different bank accounts can be simulated with a few lines of code. These sim

Anyone needs a graphdb written in Python?

2016-11-22 Thread Amirouche Boubekki
Héllo, I am working on a graphdb written Python on top of wiredtiger. Anyone want to share about the subject about where this could be made useful? TIA! -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Steven Truppe
I've made a pastebin with a few examples: http://pastebin.com/QQQFhkRg On 2016-11-22 21:33, Steven Truppe wrote: I all, i'm using linux and python 2 and want to parse a file line by line by executing a command with the line (with os.system). My problem now is that i'm opening the file and

Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Steven Truppe
I all, i'm using linux and python 2 and want to parse a file line by line by executing a command with the line (with os.system). My problem now is that i'm opening the file and parse the title but i'm not able to get it into a normal filename: import os,sys import urlib,re,cgi import HT

Re: Numpy slow at vector cross product?

2016-11-22 Thread BartC
On 22/11/2016 16:48, Steve D'Aprano wrote: On Tue, 22 Nov 2016 11:45 pm, BartC wrote: I will have a look. Don't forget however that all someone is trying to do is to multiply two vectors. They're not interested in axes transformation or making them broadcastable, whatever that means. You don

Re: Guido? Where are you?

2016-11-22 Thread Jon Ribbens
On 2016-11-22, Gilmeh Serda wrote: > On Mon, 21 Nov 2016 00:53:33 -0800, Ethan Furman wrote: >> Unfortunately, we do not have any control over the comp.lang.python >> newsgroup > > Gee, "unfortunately"? Really!? Gosh! I'm glad I don't have to live > anywhere close to you. 8·[ > > NOBODY "owns" th

Re: How to you convert list of tuples to string

2016-11-22 Thread Michiel Overtoom
Hi Ganesh, > Any better suggestion to improve this piece of code and make it look more > pythonic? import random # A list of tuples. Note that the L behind a number means that the number is a 'long'. data = [(1, 1, 373891072L, 8192), (1, 3, 390348800L, 8192), (1, 4, 372719616L, 8192), (2

Re: Numpy slow at vector cross product?

2016-11-22 Thread Steve D'Aprano
On Tue, 22 Nov 2016 11:45 pm, BartC wrote: > I will have a look. Don't forget however that all someone is trying to > do is to multiply two vectors. They're not interested in axes > transformation or making them broadcastable, whatever that means. You don't know that. Bart, you have a rather di

How to you convert list of tuples to string

2016-11-22 Thread Ganesh Pal
Dear friends , I am using fedora 18 and on Python 2.7 version I have a list of tuples as shown below >> list [(1, 1, 373891072L, 8192), (1, 3, 390348800L, 8192), (1, 4, 372719616L, 8192), (2, 3, 382140416L, 8192), (2, 5, 398721024L, 8192), (3, 1, 374030336L, 8192), (3, 3, 374079488L, 8192),

Re: Numpy slow at vector cross product?

2016-11-22 Thread BartC
On 22/11/2016 12:45, BartC wrote: On 22/11/2016 12:34, Skip Montanaro wrote: I'm simply suggesting there is plenty of room for improvement. I even showed a version that did *exactly* what numpy does (AFAIK) that was three times the speed of numpy even executed by CPython. So there is some myste

Re: Numpy slow at vector cross product?

2016-11-22 Thread eryk sun
On Tue, Nov 22, 2016 at 1:06 PM, BartC wrote: >> In this specific example, the OP is comparing two radically different >> pieces of code that clearly and obviously perform differently. He's doing >> the equivalent of timing the code with his heartbeat, and getting 50 beats >> for one and 150 beats

Re: Numpy slow at vector cross product?

2016-11-22 Thread BartC
On 22/11/2016 03:00, Steve D'Aprano wrote: On Tue, 22 Nov 2016 12:45 pm, BartC wrote: You get to know after while what kinds of processes affect timings. For example, streaming a movie at the same time. Really, no. py> with Stopwatch(): ... x = math.sin(1.234) ... elapsed time is very

Re: Numpy slow at vector cross product?

2016-11-22 Thread BartC
On 22/11/2016 12:34, Skip Montanaro wrote: I'm simply suggesting there is plenty of room for improvement. I even showed a version that did *exactly* what numpy does (AFAIK) that was three times the speed of numpy even executed by CPython. So there is some mystery there. As I indicated in my ear

Re: Numpy slow at vector cross product?

2016-11-22 Thread Skip Montanaro
> I'm simply suggesting there is plenty of room for improvement. I even showed a version that did *exactly* what numpy does (AFAIK) that was three times the speed of numpy even executed by CPython. So there is some mystery there. As I indicated in my earlier response, your version doesn't pass all

Re: Numpy slow at vector cross product?

2016-11-22 Thread BartC
On 22/11/2016 02:44, Steve D'Aprano wrote: On Tue, 22 Nov 2016 05:43 am, BartC wrote: The fastest I can get compiled, native code to do this is at 250 million cross-products per second. (Actually 300 million using 64-bit code.) Yes, yes, you're awfully clever, and your secret private langua

Re: Result is not Displayed

2016-11-22 Thread Peter Otten
prihantoro2...@gmail.com wrote: > Dear all, > > i am new to Python and have this problem > > = > import nltk > puzzle_letters = nltk.FreqDist('egivrvonl') > obligatory = 'r' > wordlist = nltk.corpus.words.words() > [w for w in wordlist if len(w) >= 6 > and obligatory in w > and nltk.FreqDist

Re: Result is not Displayed

2016-11-22 Thread Irmen de Jong
On 22-11-2016 9:18, prihantoro2...@gmail.com wrote: > Dear all, > > i am new to Python and have this problem > > = > import nltk > puzzle_letters = nltk.FreqDist('egivrvonl') > obligatory = 'r' > wordlist = nltk.corpus.words.words() > [w for w in wordlist if len(w) >= 6 > and obligatory in w

Result is not Displayed

2016-11-22 Thread prihantoro2001
Dear all, i am new to Python and have this problem = import nltk puzzle_letters = nltk.FreqDist('egivrvonl') obligatory = 'r' wordlist = nltk.corpus.words.words() [w for w in wordlist if len(w) >= 6 and obligatory in w and nltk.FreqDist(w) <= puzzle_letters] print puzzle_letters == this

Re: Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-22 Thread Gene Heskett
On Monday 21 November 2016 22:20:40 Chris Angelico wrote: > On Tue, Nov 22, 2016 at 2:10 PM, wrote: > > Hi! This is my first post! I'm having trouble understanding my code. > > I get "SyntaxError:invalid syntax" on line 49. I'm trying to code a > > simple text-based rpg on repl.it. Thank you for