[Tutor] Fwd: python qn

2014-09-11 Thread Danny Yoo
Forwarding to python-tutor. -- Forwarded message -- From: Carmel O'Shannessy Date: Thu, Sep 11, 2014 at 12:18 PM Subject: Re: [Tutor] python qn To: Danny Yoo thanks, this worked: times2 = [float(i) for i in times[:2]] On Thu, Sep 11, 2014 at 1:10 PM, Danny Yoo wrote: > > On

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Peter Otten
Juan Christian wrote: > On Thu, Sep 11, 2014 at 5:23 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> You are getting an *encoding* error, so this may be triggered when you >> are trying to print. Can you post the traceback? >> >> Also, what is your OS and what does >> >> $ python3 -c'import loc

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
On Thu, Sep 11, 2014 at 5:23 PM, Peter Otten <__pete...@web.de> wrote: > > > You are getting an *encoding* error, so this may be triggered when you are > trying to print. Can you post the traceback? > > Also, what is your OS and what does > > $ python3 -c'import locale; print(locale.getpreferredenc

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Peter Otten
Juan Christian wrote: > On Thu, Sep 11, 2014 at 4:39 PM, Juan Christian > wrote: >> >> Using 3.4.1 >> >> I did try: >> >> self.persona_name = unicode(personaname) >> self.persona_name = personaname.decode("utf-8") >> >> But didn't work! >> > > > Some of the chars that brakes the program: > > \

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
On Thu, Sep 11, 2014 at 4:39 PM, Juan Christian wrote: > > Using 3.4.1 > > I did try: > > self.persona_name = unicode(personaname) > self.persona_name = personaname.decode("utf-8") > > But didn't work! > Some of the chars that brakes the program: \u0183 \u2020 \u0361 \u0649 And many others cra

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
Forget to tell, sorry. I'm using Python 3.4.1 On Thu, Sep 11, 2014 at 3:53 PM, Sebastian Silva wrote: > Hi, > Python 2 suffers from these kinds of issues frequently. > > However Python 3 does not. > > Now, to deal with different encodings in Python 2 you need to cast to > unicode type, and then

[Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
I'm iterating through Steam users and friend lists. So, my program was working good, but then I got some UnicodeEncodeError randomly, I didn't know where was the problem, then I was checking the names that I got from the API by hand, and then I saw users with ™, ︻デ═一, ︻芫, º³® and tons of other

Re: [Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Juan Christian
Done. thanks guys. On Thu, Sep 11, 2014 at 2:43 PM, Danny Yoo wrote: > > On Thu, Sep 11, 2014 at 2:09 PM, Peter Otten <__pete...@web.de> wrote: > >> > >> > >> You can explode the list by invoking the function with > >> > >> fetch_users(*my_list) # prepend the list with a star > >> > >> but I rec

Re: [Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Danny Yoo
> On Thu, Sep 11, 2014 at 2:09 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> You can explode the list by invoking the function with >> >> fetch_users(*my_list) # prepend the list with a star >> >> but I recommend that you change the function's signature to >> >> def fetch_users(steamids): >>

Re: [Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Juan Christian
On Thu, Sep 11, 2014 at 2:07 PM, Danny Yoo wrote: > > > Hi Juan, > > You have a "var-arity" function called fetch_users(), and you'd like > to apply it with an explicit list of arguments "my_list". > > In this case, you want to use the application operator: > > > https://docs.python.org/2/tutorial

Re: [Tutor] python qn

2014-09-11 Thread Peter Otten
Carmel O'Shannessy wrote: > times = ['50.319468', '50.319468', 't1'] > > I want to convert [0:2] to floats. > > I tried: > > float.times = [float(i) for i in times[:2]] > > but get the error msg: > > TypeError: can't set attributes of built-in/extension type 'float' Try times[:2] = [floa

Re: [Tutor] python qn

2014-09-11 Thread Danny Yoo
On Thu, Sep 11, 2014 at 8:08 AM, Carmel O'Shannessy wrote: > > Hello, > > times = ['50.319468', '50.319468', 't1'] > > I want to convert [0:2] to floats. > > I tried: > > float.times = [float(i) for i in times[:2]] Hi Carmel, Do you intend to have a variable named "float.times" here on the le

Re: [Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Peter Otten
Juan Christian wrote: > Let's say I have the following list: my_list = ['76561198048214059', > '76561198065852182', '76561198067017670', '76561198077080978', > '76561198077257977', '7656119807971 > 7745', '76561198088368223', '76561198144945778'] > > and I have a function with the following signa

Re: [Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Danny Yoo
On Thu, Sep 11, 2014 at 9:42 AM, Juan Christian wrote: > Let's say I have the following list: my_list = ['76561198048214059', > '76561198065852182', '76561198067017670', '76561198077080978', > '76561198077257977', '7656119807971 > 7745', '76561198088368223', '76561198144945778'] > > and I have a f

[Tutor] python qn

2014-09-11 Thread Carmel O'Shannessy
Hello, times = ['50.319468', '50.319468', 't1'] I want to convert [0:2] to floats. I tried: float.times = [float(i) for i in times[:2]] but get the error msg: TypeError: can't set attributes of built-in/extension type 'float' Carmel -- -- Carmel O'Shannessy, Assoc. Prof. Department of

[Tutor] Convert a list to a group of separated strings

2014-09-11 Thread Juan Christian
Let's say I have the following list: my_list = ['76561198048214059', '76561198065852182', '76561198067017670', '76561198077080978', '76561198077257977', '7656119807971 7745', '76561198088368223', '76561198144945778'] and I have a function with the following signature: def fetch_users(*steamids) U

Re: [Tutor] Problem understanding the asarray function of numpy

2014-09-11 Thread Emile van Sebille
On 9/11/2014 6:34 AM, Radhika Gaonkar wrote: I have an implementation of lsa, that I need to modify. I am having some trouble understanding the code. This is the line where I am stuck: DocsPerWord = sum(asarray(self.A > 0, 'i'), axis=1) Python doesn't provide an axis parameter for the sum buil

Re: [Tutor] Good approach regarding classes attributes

2014-09-11 Thread Danny Yoo
> I've just again experienced a new employer that tells my students my > name is 'Van Den Broek' when I tell them that it is 'van den Broek.' > This is the third time this week I've encountered this as a > programming example. Perhaps the use of the example is responsible for > the false belief amo

Re: [Tutor] Problem understanding the asarray function of numpy

2014-09-11 Thread Peter Otten
Radhika Gaonkar wrote: > I have an implementation of lsa, that I need to modify. I am having some > trouble understanding the code. This is the line where I am stuck: > > DocsPerWord = sum(asarray(self.A > 0, 'i'), axis=1) > > The link for this implementation is : > http://www.puffinwarellc.com/

Re: [Tutor] Re subprocess

2014-09-11 Thread jarod...@libero.it
Thanks for the suggestion and corrections. I don't put the else staement onf if log_file but now I realize my mistake I have 3 comand to do: step_1_out =["STAR --genomeDir /home/sbsuser/databases/Starhg19/GenomeDir/ -- runMode alignReads --readFilesIn %s %s --runThreadN 12 --readFilesCommand z

[Tutor] Problem understanding the asarray function of numpy

2014-09-11 Thread Radhika Gaonkar
I have an implementation of lsa, that I need to modify. I am having some trouble understanding the code. This is the line where I am stuck: DocsPerWord = sum(asarray(self.A > 0, 'i'), axis=1) The link for this implementation is : http://www.puffinwarellc.com/index.php/news-and-articles/articles/3

Re: [Tutor] Good approach regarding classes attributes

2014-09-11 Thread Brian van den Broek
On 7 September 2014 21:01, Danny Yoo wrote: > Let's use a concrete example: say that we'd like to make sure a > Person's name is always capitalized. We might try to enforce this > capitalization property in the constructor. Hi all, I've just again experienced a new employer that tells my