Re: [Tutor] create numpy array from list of strings

2008-06-03 Thread Danny Yoo
I actually thought this would be as simple as the 'load' command to get the data in from a file. But I just couldn't find the documentation online to do it once i have the data already 'inside' of python as a list. So, my options are: Hello, If you already have the values as a list of rows, w

Re: [Tutor] create numpy array from list of strings

2008-06-03 Thread Danny Yoo
ave good familiarity with list comprehensions. Given that you've already used to them, if what you're trying to do doesn't immediately admit a solution with list comprehensions, that's usually a good mental warning sign: don't! "Danny Yoo-3 wrote: Alhtough it&#x

Re: [Tutor] tutor list equivalent for lisp?

2008-06-05 Thread Danny Yoo
But i only play with Lisp these days so am well out of date. The best Lisp tutorial IMHO is the How To Design Programs web site/book (htdp.org?) Yes, HTDP is one of the very good ones. I'd strongly recommend it. As a full disclosure thing: I'm involved with the folks doing HTDP: I'm not a n

Re: [Tutor] do I need f.close()

2008-06-10 Thread Danny Yoo
f = open(conf, 'w') f.writelines(lines) f.close() Is it as safe to use the following open(conf, 'w').writelines(lines) ie no close() to flush the data, but also not assigned an object name so am I right in thinking that as the object is 'reclaimed' close() is automatically called ?

Re: [Tutor] inserting a vector into an array - numpy Q

2008-06-10 Thread Danny Yoo
I know there must be a better way to do this with slices, but I can't seem to figure it out - I keep getting errors about the need to have the same dimensions: Look at the error message more closely. ValueError: arrays must have same number of dimensions What does this mean? The 1-d a

Re: [Tutor] my own error code when no argument is sent

2008-06-16 Thread Danny Yoo
when i execute my program without an argument i receive, > > > infile = sys.argv[1] > > IndexError: list index out of range > > is there a way that i could suppress this and add my own error code The direct way to handle this is to check the length of sys.argv first. sys.argv is a list, so you

Re: [Tutor] Python Gotcha - List Question

2008-06-16 Thread Danny Yoo
On Tue, Jun 17, 2008 at 12:14 AM, Guess?!? <[EMAIL PROTECTED]> wrote: > Exercise 17.6 Write a definition for a class named Kangaroo with the > following methods: [cut] Be careful about asking for homework help. We're restricted from giving much help on homework questions. The error message you

Re: [Tutor] Create file and input text

2008-06-28 Thread Danny Yoo
>> #!/usr/bin/python > > > > import os > > filename = raw_input('Enter the filename: ') > > fobj = open(filename, 'w') > > yourname = raw_input('What is your name: ') > > fobj.write(yourname) > > fobj.close() > > > > It seems to work Ok, I was shocked! Is it OK? Hi David, The fir

Re: [Tutor] Is "var = None" in Python equivalent to "Set var

2008-06-29 Thread Danny Yoo
> As I understand it there are no cases where obj==None and obj is None > will give different results I hate going off track, but: ## class CounterExample: def __eq__(self, other): return True print "is?", CounterExample() is None print "==", Count

Re: [Tutor] Another assert() question

2008-07-12 Thread Danny Yoo
> In my code I have > > assert(len(list(set(colors_used_this_cycle))) == > len(colors_used_this_cycle), "A color has been used twice!") > > But it doesn't work. Cases where a color has been used more than once go > right through it Let's try a simple example. Go back to the structure of an asse

Re: [Tutor] Python Assistance!

2008-07-24 Thread Danny Yoo
On Thu, Jul 24, 2008 at 12:54 PM, <[EMAIL PROTECTED]> wrote: > Hi, this is my first time come to this website to ask about python question. > I'm totally don't know how to do my last assignment.It is distance education > class, and my taxt book DOES NOT show exactly information for me to do this >

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-28 Thread Danny Yoo
> 1. I need to find the sum of all numbers at even positions in the > Fibonacci series upto 2 million. > > 2. I have used lists to achieve this. I see. You may want to produce a "sequence" or "iterator" of fibonacci numbers rather than an explicit list. As it is, your machine does not ha

Re: [Tutor] Why use lambda?

2008-08-02 Thread Danny Yoo
> What can lambda do that normal function definitions cannot? > Is it quicker to execute/less memory intensive? > Or is it just quicker to type and easier to think about? Notational convenience. Think about how, in arithmetic expressions, how we're not forced to give explicit names to all the sub

Re: [Tutor] Regular expression to match \f in groff input?

2008-08-21 Thread Danny Yoo
On Thu, Aug 21, 2008 at 1:40 PM, Bill Campbell <[EMAIL PROTECTED]> wrote: > I've been beating my head against the wall try to figure out how > to get regular expressions to match the font change sequences in > *roff input (e.g. \fB for bold, \fP to revert to previous font). > The re library maps r'

Re: [Tutor] Tutor Archives and PC Crash

2008-09-30 Thread Danny Yoo
Yup. See: http://mail.python.org/pipermail/tutor/ for the archive. There's also a searchable interface from GMANE: http://dir.gmane.org/gmane.comp.python.tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] Finding the "streaks" in heads/tails list

2008-10-01 Thread Danny Yoo
> Regular expressions are for processing strings, not loops. >From a theoretical point of view, this isn't quite true: regular expressions can deal with sequences of things. It's true that most regular expression libraries know how to deal only with characters, but that's a matter of specializing

Re: [Tutor] documentation tut.html Error 404

2008-10-17 Thread Danny Yoo
On Fri, Oct 17, 2008 at 11:57 AM, Marco <[EMAIL PROTECTED]> wrote: > hi list, > > the link provided in one of the initiation mails from the tutor-mailinglist: > > ... > http://www.python.org/doc/current/tut/tut.html Ok, thanks. This should be fixed now. The link appears to have moved to: ht

Re: [Tutor] Fraction - differing interpretations for number and string - presentation

2015-04-16 Thread Danny Yoo
On Apr 16, 2015 1:42 PM, "Jim Mooney" wrote: > Understood about the quondam inexactness of floating point bit > representation. I was just wondering why the different implementation of > representing it when using Fraction(float) as opposed to using > Fraction(string(float)). Ah. Correction. Y

Re: [Tutor] introspection

2015-04-20 Thread Danny Yoo
What's supposed to happen in this situation? ## class Person(object): def __init__(self): pass j = Person() john = j jack = j ## What single name should we get back from the single Person object here? "j", "joh

Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Danny Yoo
On Apr 21, 2015 12:24 AM, "Jim Mooney" wrote: > > Why does the compiler choke on this? It seems to me that the enhanced > subtraction resolves to a legitimate integer in the exponent, but I get a > syntax error: > > B = '11011101' > sum = 0 > start = len(B) > for char in B: > sum += int(char)

Re: [Tutor] what's wrong with this ?

2015-04-21 Thread Danny Yoo
On Apr 21, 2015 12:27 AM, "lei yang" wrote: > > >>>start_time = "2014-7-1" > >>> revlines = commands.getoutput("git log --pretty=format:'%ad:%an' > --date=short --since='%s' --no-merges" %start_time).strip().split('\n') > Traceback (most recent call last): > File "", line 1, in > ValueError: un

Re: [Tutor] introspection

2015-04-21 Thread Danny Yoo
> But I see what I think you and others have been trying to explain to me: > that the expression some_object.__name__, if it existed, would indeed be > schizophrenic since it would be an attribute of the object, not the name(s) > to which it is bound. The hypothetical feature might also, if desi

[Tutor] Looking up a value in a dictionary

2015-04-25 Thread Danny Yoo
On Sat, Apr 25, 2015 at 11:13 AM, Juanald Reagan wrote: > Okay, so it doesn't look like that worked...here is the traceback. I don't > understand the second part of your request. > > Jons-desktop:whois-0.7 2 jon$ python pythonwhois.py > > 8.8.8.8 > > Traceback (most recent call last): > > File "

Re: [Tutor] REPL format

2015-04-25 Thread Danny Yoo
On Sat, Apr 25, 2015 at 4:38 PM, Jim Mooney wrote: > I'm curious why, when I read and decode a binary file from the net in one > fell swoop, the REPL prints it between parentheses, line by line but with > no commas, like a defective tuple. The REPL is trying to be nice here. What you're seeing

Re: [Tutor] REPL format

2015-04-25 Thread Danny Yoo
> I would strongly discourage not using it yourself in your own > programs. Ugh. There was one too many negations there. I deserved to make that mistake, since my sentence structure was unnecessarily nested. :P I meant to say: "I would strongly discourage using literal string concatenation in

Re: [Tutor] CPU Scheduling

2015-04-27 Thread Danny Yoo
> On 27/04/15 02:18, alex gonsalez wrote: >> >> Need help trying to implement a CPU scheduling algorithm. Hi Alex, Unfortunately, this is way out of scope for Python-tutor; I think you'll be better off discussing with your classmates and professor. You'll get more productive answers that way. On

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Danny Yoo
On Wed, Apr 29, 2015 at 11:37 AM, diliup gabadamudalige wrote: > I do not understand how Alan does not get the code that is in this thread. Hi Dilliup, Please try to avoid using the phrase, "I don't understand how does not get ...". You might not realize it, but it's radioactive: it's has a v

Re: [Tutor] Is there a way to store and later use comparison operators (<, <=, =, >=, >) ?

2015-04-29 Thread Danny Yoo
Hi Bob, By the way, it sounds like you're starting to learn about how to write interpreters. If that's the case, you might find PLAI helpful: http://cs.brown.edu/~sk/Publications/Books/ProgLangs/ helpful. (Full disclosure: the author was my external advisor. :P) Another good book is EoP

[Tutor] Jacob Kaplan-Moss's keynote at PyCon 2015

2015-05-04 Thread Danny Yoo
Apologies: this is somewhat off-topic, but I thought it might resonate with the audience here: https://www.youtube.com/watch?v=hIJdFxYlEKE It reminds me of Camille Fournier's talk back in 2014 at BangBangCon: https://www.youtube.com/watch?v=sc8sc-ELMhA Both express the experience of bei

Re: [Tutor] formatting strings

2015-05-08 Thread Danny Yoo
> I am trying to make a binary counter that will prompt for and read a decimal > number (whole number). Then display all decimal numbers starting from 1 up to > and including the decimal number entered along with the binary representation > of the numbers to the screen. You might consider writi

Re: [Tutor] reading lines from a list of files

2015-05-13 Thread Danny Yoo
> As a follow up question: > The following seems to work- > > for f_name in list_of_file_names: > for line in open(f_name, 'r'): > process(line) > > but should I be worried that the file doesn't get explicitly closed? It depends on context. Personally, I'd write it with t

[Tutor] Stem and leaf plots

2015-05-17 Thread Danny Yoo
I was reading the "Cartoon Guide to Statistics", and came across a description on "Stem and plot diagrams". (http://en.wikipedia.org/wiki/Stem-and-leaf_display.) It's sorta like a histogram diagram, but bundles by the ten's digit, and uses the one's digit as the "point". Here's my attempt at desc

Re: [Tutor] Stem and leaf plots

2015-05-17 Thread Danny Yoo
> for i in range(low, high+1): > stems[i].sort() > print(str(i).ljust(padding) + ' | ' + > ' '.join(map(str, stems[i])))def printStemPlot(values): Gah! Sorry! Copy and paste error near the end there. Just trim the 'def printStemPlot(values):' part off the end

Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Danny Yoo
> ls *.pyc *.pso >> .hidden > > should work > > root@localhost:~# mkdir hide_test [My response is completely off topic of Python; apologies.] Hi Bod, Be careful about running as 'root' for normal exploratory programming or system usage. 'root' should be treated as an emergency-mode kind of thin

Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Danny Yoo
>> I just created an alias for this: >> alias hidepycs="ls *.py[co] > .hidden" > > Close -- try > > alias ls='ls --hide=*.py[co]' > > and when you want to see them use ls -a. +1 to Emile's approach. This seems to be the right approach, using the "--hide" option built into ls: --hide=PATT

Re: [Tutor] ls *.py[co] >> .hidden

2015-05-22 Thread Danny Yoo
>> I thought we'd established that this was to >> control visibility in the File Manager GUI >> not the CLI? So an 'ls' flag isn't going to >> help there. > > > Yes, it was about the visibility in Nautilius. Much easier on the eye when > the bytecode files are not visible. Ah, I was confused the

Re: [Tutor] Generate Prime Numbers

2015-05-30 Thread Danny Yoo
I'll review the code a bit. > import time > > starttime=time.time() > > class Number: > def __init__(self,number,p=None,n=None): > self.no=number > self.marked=None > self.p=p > self.n=n It would be helpful to document what the types of 'p' and 'n' are here.

Re: [Tutor] R: Tutor Digest, Vol 136, Issue 19

2015-06-08 Thread Danny Yoo
On Mon, Jun 8, 2015 at 1:12 PM, jarod_v6--- via Tutor wrote: > Thanks for the help!! The data I put unfortunately was runcated: > ENSG0267199 11.81567500371.74423209120.5103558647 > 3.4176781572 > 0.00063157740.0122038731ENSG0267199 NA NA NA > ENSG

Re: [Tutor] moving objects in only one direction at a time

2015-06-11 Thread Danny Yoo
In an event-driven game, you need to give control back to the event loop in order for the framework to pass events to your program. Your main function, however, doesn't do so: you've got a while loop that monopolizes control flow: def game(): # ... game initialization logic while playing:

Re: [Tutor] memory error

2015-06-30 Thread Danny Yoo
On Tue, Jun 30, 2015 at 8:10 AM, Joshua Valdez wrote: > So I wrote this script to go over a large wiki XML dump and pull out the > pages I want. However, every time I run it the kernel displays 'Killed' I'm > assuming this is a memory issue after reading around but I'm not sure where > the memory

Re: [Tutor] memory error

2015-06-30 Thread Danny Yoo
> > *Joshua Valdez* > *Computational Linguist : Cognitive Scientist >* > > (440)-231-0479 > jd...@case.edu | j...@uw.edu | jo...@armsandanchors.com > <http://www.linkedin.com/in/valdezjoshua/> > > On Tue, Jun 30, 2015 at 7:27 PM, Danny Yoo wrote: > >

Re: [Tutor] memory error

2015-06-30 Thread Danny Yoo
Hi Joshua, The issue you're encountering sounds like XML namespace issues. >> So I tried that code snippet you pointed me too and I'm not getting any >> output. This is probably because the tag names of the XML are being prefixed with namespaces. This would make the original test for node.

Re: [Tutor] memory error

2015-07-02 Thread Danny Yoo
On Thu, Jul 2, 2015 at 9:57 AM, Joshua Valdez wrote: > > Hi so I figured out my problem, with this code and its working great but its > still taking a very long time to process...I was wondering if there was a way > to do this with just regular expressions instead of parsing the text with > lxm

Re: [Tutor] memory error

2015-07-02 Thread Danny Yoo
> > So I got my code working now and it looks like this > > TAG = '{http://www.mediawiki.org/xml/export-0.10/}page' > doc = etree.iterparse(wiki) > > for _, node in doc: > if node.tag == TAG: > title = > node.find("{http://www.mediawiki.org/xml/export-0.10/}title";).text > if t

Re: [Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Danny Yoo
On Thu, Jul 2, 2015 at 12:30 PM, Jim Mooney Py3.4.3winXP wrote: > When an instance uses a class method, does it actually use the method that > is in the class object's memory space, or is the method copied to the > instance? Unsure. How would it be observable? [The following is not beginner

Re: [Tutor] Variable reference

2015-07-06 Thread Danny Yoo
I'd also add that the 'del' statement has near-zero utility. 'del' is a language blemish. It should not be used by beginners, because it asks them to try to manually manage the lifetime of their variable names. That's an unreasonable and ridiculous burden. Functions have local variables for a re

Re: [Tutor] Variable reference

2015-07-07 Thread Danny Yoo
>> It's a work-around for the fact that >> Python doesn't have dedicated syntax to say "operate on the reference >> foo" rather than the value of foo. > > I think Danny's point was that you should not micromanage name bindings at > all. Then Alan added that del is useful for dicts etc. on which I r

Re: [Tutor] Not very nice Marilyn Davis person

2015-07-11 Thread Danny Yoo
On Sat, Jul 11, 2015 at 6:35 PM, c.fryer via Tutor wrote: > > why is this listed under my name? C.ya! Hi C Fryer, A good rule of thumb, when working with communities of people with incomplete knowledge, is to give folks the benefit of the doubt. Email is an information-poor medium for communicat

Re: [Tutor] Socket Module

2015-07-12 Thread Danny Yoo
One other thing to note: if you're working with a comma-separated value file (CSV), then you may want to use the 'csv' module to parse it. https://docs.python.org/3.5/library/csv.html This should allow you to walk through the file as if it were a sequence of records. In contrast, if you're d

Re: [Tutor] Socket Module

2015-07-18 Thread Danny Yoo
On Jul 18, 2015 3:50 PM, "Nym City via Tutor" wrote: > > Thank you all for your responses. I have a follow up question: > > So if gethostbyname_ex() takes only a single hostname string, how can I use it to go through a list of hostnames and get their IP resolution as an output? > Look into loops.

Re: [Tutor] Socket Module

2015-07-19 Thread Danny Yoo
> for name in domains: > socket.gethostbyaddr(name) > print(name) > > output: > 173.252.120.6 > 98.139.183.24 > > What am I missing? Thank in advance. > You have confused yourself a little because the variable names you've chosen are slightly misleading. Specifically, "name" is really an

Re: [Tutor] mailing list

2015-07-28 Thread Danny Yoo
On Jul 28, 2015 12:38 PM, "mikablom via Tutor" wrote: > > > > I forgot how to stop getting mails from you all. please, will someone tell me how. thank you very much. Visit https://mail.python.org/mailman/listinfo/tutor; you should be able to unsubscribe from there. ___

Re: [Tutor] the big o

2015-07-28 Thread Danny Yoo
> I took Intro to Programming at Albright College and we used Starting Out with > Python 3rd ed. Right now I am taking Data Structure and Analysis and we are > using This book : > http://interactivepython.org/runestone/static/pythonds/BasicDS/InfixPrefixandPostfixExpressions.html > > Thanks Alan

Re: [Tutor] mbox-short

2015-07-29 Thread Danny Yoo
> How do I file in the empty list at 0 on line # 3 to produce the desired output: What trouble are you having? Please try to describe where you are getting stuck. What have you tried? Is there anything confusing? Also note that a few of your peers have asked the exact same homework assignment

Re: [Tutor] Basic question about docstrings

2015-07-29 Thread Danny Yoo
On Jul 29, 2015 12:45 PM, "David Aldrich" wrote: > > Hi > > If I have a script called main.py and document a function in it: > > def get_value(x): > """ > Some text ... > :param x: Some value > :returns: Something useful > """ > > What is the most basic way of showing

Re: [Tutor] Basic question about docstrings

2015-07-30 Thread Danny Yoo
> > So main.py contains: > > def get_field(value, start_bit, end_bit): > > > and I see: > > >>> import main > >>> help(get_field) > Traceback (most recent call last): >File "", line 1, in > NameError: name 'get_field' is not defined > > > help(main) works ok but is rather verbose. Try:

Re: [Tutor] infix to postfix exponent handling

2015-08-01 Thread Danny Yoo
> i also replaced the infixtopostfix to the problem: > > ("5 * 3 ^ (4 - 2)”)) > > here is the error I am getting : > > Traceback (most recent call last): > File "/Users/stephaniequiles/Downloads/Listings/listing_3_7.py", line 53, > in > print(infixToPostfix("5 * 3 ^ (4 - 2)")) > File "/Us

Re: [Tutor] email validation

2015-08-01 Thread Danny Yoo
All your function definitions should be defined with 'def' at the leftmost margin. However, the line in your program that starts with "def open_existing_file()..." is not flush with the margin. Python has, subsequently, thought that the definition of the function is scoped locally. Move the begi

Re: [Tutor] email validation

2015-08-01 Thread Danny Yoo
On Sat, Aug 1, 2015 at 2:03 PM, Válas Péter wrote: > Hi Stephanie, > > the function should be defined first, and used after. So put it before > main(). It's perfectly legal and ok to say: ### def main(): callHelper() def callHelper(): print("I am the helper")

Re: [Tutor] for loop for long numbers

2015-08-03 Thread Danny Yoo
> Hi to all. > Can you help me plz. > I want to make a for loop with a huge numbers. > for example: > > for i in range (0,90): > make_some_code Can you say more why you are trying to do this, by the way? Without context, this request seems strange, as we often want to make our programs

Re: [Tutor] About Python Module to Process Bytes

2015-08-04 Thread Danny Yoo
On Tue, Aug 4, 2015 at 9:26 AM, Michelle Meiduo Wu wrote: > Hi there, > I'd like to find some python module to easily process bytes array data, like > encoding different types of data (char, long, short, float, etc) into a same > bytes array. I checked Python built-in library and there are bytes

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Danny Yoo
> However, there is a traceback message: > > In [40]: %run 9_4_4.py > File "C:\Users\vm\Desktop\apps\docs\Python\_9_4_4.py", line 19 > count = dict() > ^ > SyntaxError: invalid syntax Syntax error reporting is approximate: you might need to look a few lines earlier to get at the root

Re: [Tutor] How to test my code's interactions with SQLite db?

2015-08-16 Thread Danny Yoo
Hi Bob, By the way, when you're unit testing with Sqlite, you might find it convenient to use the ":memory:" option, which keeps the database in RAM rather than on disk. That should make the "setup" and "tear-down" of the testing environment easier to maintain. The principle is similar to that o

Re: [Tutor] gensim to generate document vectors

2015-08-17 Thread Danny Yoo
>> I'm getting the vocab fine with my code but I can't seem to figure out how >> to print out the individual sentence vectors, I have looked through the >> documentation and haven't found much help. Here is what my code looks like >> so far. It appears that you're asking this question on Stack Ove

Re: [Tutor] gensim to generate document vectors

2015-08-17 Thread Danny Yoo
Followup: If we want to get at the document vectors after training, I think that, from reading the code here: https://github.com/piskvorky/gensim/blob/develop/gensim/models/doc2vec.py#L254 that you want to get at the model's 'docvecs' attribute. We know it's a DocvecArray because it is as

[Tutor] Fwd: Re: Binary tree expressions

2015-08-18 Thread Danny Yoo
Apologies for not sending this to the list. Forwarding. -- Forwarded message -- From: "Danny Yoo" Date: Aug 18, 2015 4:12 PM Subject: Re: [Tutor] Binary tree expressions To: "Stephanie Quiles" Cc: On Aug 18, 2015 3:48 PM, "Quiles, Stephanie" <

Re: [Tutor] Help error 504

2015-08-25 Thread Danny Yoo
In your program, you have a try/ except block, but it does not surround the line: req=urllib.request.urlopen(''+line) You probably should modify the extent of the exception handling to include that part. If you are seeing a 504, I expect it to come at this point. __

Re: [Tutor] Help error 504

2015-08-25 Thread Danny Yoo
Unit tests that depend on external dependencies can be "flaky": they might fail for reasons that you don't anticipate. I'd recommend not depending on an external web site like this: it puts load on someone else, which they might not appreciate. Making the test not depend on the network is not ba

Re: [Tutor] Creating lists with definite (n) items without repetitions

2015-09-03 Thread Danny Yoo
> At first I thought you might want itertools.combinations() > import string, itertools for t in itertools.combinations(string.ascii_lowercase, 3): > ... print t # list(t) if you actually need a list > ... > ('a', 'b', 'c') > ('a', 'b', 'd') > ('a', 'b', 'e') > ('a', 'b', 'f') > ('a',

Re: [Tutor] Syntax error and EOL Error

2015-09-13 Thread Danny Yoo
On Sun, Sep 13, 2015 at 7:20 AM, Nym City via Tutor wrote: > Hello, > Sorry for the late response. It took me sometime to find the solution. Below > is my updated code which seems to be working fine now. Just wanted to share > with the group here. > > import csv > DomainList = [] > > domains = o

Re: [Tutor] ​How to use the returned telnet object after creating the telnet session.

2015-09-13 Thread Danny Yoo
On Sun, Sep 13, 2015 at 12:29 AM, Manju M wrote: > > Assume that I will pass IP and port information from a function to open the > telnet session. have opened the telnet session and after opening the telnet > session I returned telnet object to calling function. Hi Manju, I apologize for potent

Re: [Tutor] [newbie] import error after restart (virtualenv)

2015-09-19 Thread Danny Yoo
On Sep 19, 2015 6:22 PM, "David" wrote: > > Hello Peter, > > this was indeed the problem -- I didn't go through manage.py! Weird I > didn't have that on the radar anymore. > > Putting lists/ onto the Python path did not solve the problem. > You probably want to put the *parent* of lists/ onto the

Re: [Tutor] generate a list/dict with a dynamic name..

2015-09-27 Thread Danny Yoo
On Sun, Sep 27, 2015 at 9:38 AM, bruce wrote: > Hi. > > I can do a basic > a=[] > to generate a simple list.. > > i can do a a="aa"+bb" > > how can i do a > a=[] > > where a would have the value of "aabb" > > in other words, generate a list/dict with a dynamically generated name There is a con

Re: [Tutor] mathematical and statistical functions in Python

2015-09-27 Thread Danny Yoo
On Fri, Sep 25, 2015 at 3:58 AM, Michel Guirguis wrote: > Good afternoon, > > Thanks for your e-mail. I did not receive e-mail from Mr Otten.Basically, the > problem that I am facing is that python 3.4 does not recognise the > mathematical and statistical functions. Many mathematical functions

Re: [Tutor] xunit unittest.TestSuite

2015-09-27 Thread Danny Yoo
On Sat, Sep 26, 2015 at 10:25 AM, vijayram wrote: > Hi All, > > I am facing this same issue described here: > https://github.com/nose-devs/nose/issues/542 > > > any alternative or solution to this issue that anyone is aware of... please > kindly s

Re: [Tutor] stx, etx (\x02, \x03)

2015-09-27 Thread Danny Yoo
On Tue, Sep 22, 2015 at 5:37 AM, richard kappler wrote: > I have a file with several lines. I need to prepend each line with \x02 and > append each line with \x03 for reading into Splunk. I can get the \x02 at > the beginning of each line, no problem, but can't get the \x03 to go on the > end of t

Re: [Tutor] Opencv

2015-09-27 Thread Danny Yoo
> This list is for people learning Python programming with the standard > library. opencv is a large third party set of modules for a very > specific use case. > > You will find a Q&A forum on the opencv web site: > > http://answers.opencv.org/questions/ > > This is much more likely to be able to h

Re: [Tutor] Python type confusion?

2015-09-28 Thread Danny Yoo
On Mon, Sep 28, 2015 at 1:27 PM, Ken Hammer wrote: > A simple "type" problem? > > The following code works as a py file with the XX'd lines replacing the two > later "raw_input" lines. > Why do the "raw_input" lines yield a TypeError: 'str' object is not callable? > Same result if I use/omit >

Re: [Tutor] Python type confusion?

2015-09-28 Thread Danny Yoo
> As C Smith notes, raw_input() returns a string. As the name suggests, > it treats its input as raw text, and does not try to interpret it as > data. Whoops! I slightly misspoke here: I mean to say that it does not try to interpret it as *structured* data. That is, we want things that look li

Re: [Tutor] 0 > "0" --> is there a "from __future__ import to make this raise a TypeError?

2015-10-13 Thread Danny Yoo
> In Python 2 one can do silly apple-pear comparisons such as 0> "0".*) > "CPython implementation detail: Objects of different types except numbers are > ordered by their type names; objects of the same types that don’t support > proper comparison are ordered by their address.". In Python3 this

Re: [Tutor] Guidance on using custom exceptions please

2015-10-13 Thread Danny Yoo
On Mon, Oct 12, 2015 at 7:55 AM, David Aldrich wrote: > Hi > > Consider a 'send' method that sends a message to another system via a socket. > This method will wait for a response before returning. There are two > possible error conditions: > > 1) Timeout - i.e. no response received > > 2

Re: [Tutor] how to unittest cli input

2015-10-13 Thread Danny Yoo
On Sat, Oct 10, 2015 at 5:41 PM, Alex Kleider wrote: > """ > I'm trying to follow a test driven development paradigm (using > unittest) but can't figure out how to test functions that collect > info from the command line such as the following. > """ > # collect.py > def collect_data(): > ret =

Re: [Tutor] Guidance on using custom exceptions please

2015-10-13 Thread Danny Yoo
> Then it seems that an importer of that module must include the module name > when referencing the exceptions: > > import TxControl > > try: > send(msg) > except (TxControl.MessageTimeoutError, TxControl.UndefinedMessageTypeError) > as err: > # Exception processing > > Including 'TxContr

Re: [Tutor] how to unittest cli input

2015-10-13 Thread Danny Yoo
On Tue, Oct 13, 2015 at 2:44 PM, Alex Kleider wrote: > On 2015-10-13 12:11, Danny Yoo wrote: > > >> ## >> def make_ask(f, l, p): >> d = {'Enter your first name: ' : f, >>'Enter your last name: ' : l, >

Re: [Tutor] how to unittest cli input

2015-10-14 Thread Danny Yoo
>>> ## >>> def make_ask(f, l, p): >>> d = {'Enter your first name: ' : f, >>>'Enter your last name: ' : l, >>>'Your mobile phone #: ' : p} >>> return d.get >>> ## > > > This is an example of a 'closure' is it not? Yes, though

Re: [Tutor] Probability Density Function

2015-10-19 Thread Danny Yoo
On Mon, Oct 19, 2015 at 11:23 AM, Sashen Singh wrote: > Hi, > I have an array of chi square values for different values of redshift > between 0 and 3. I know that the min-chi square value refers to the maximum > likelihood. I need to plot a probability density function using the chi > square value

Re: [Tutor] Help with return results statement.

2015-10-22 Thread Danny Yoo
An additional suggestion: > = > # Add your functions below! > def average(numbers): > total = sum(numbers) > total = total / len(numbers) > return total Don't re-assign total here. The problem is that conceptually "total" no longer represents the total in the second assignment.

Re: [Tutor] Scraping Wikipedia Table (The retruned file is empty)

2015-10-22 Thread Danny Yoo
On Thu, Oct 22, 2015 at 4:01 PM, Cynthia Alice Andrews wrote: > At this point I feel like I am wasting my time by not asking for help. I > can't figure out why the file keeps coming back empty. There are no error > message, just an empy file. Very frustrating. Unfortunately, the formatting of yo

Re: [Tutor] Scraping Wikipedia Table (The retruned file is empty)

2015-10-22 Thread Danny Yoo
On Thu, Oct 22, 2015 at 8:07 PM, Personal wrote: > I figured it out! Thanks for taking the time to respond! No problem; glad you found it. :) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.or

Re: [Tutor] How to parse large files

2015-10-27 Thread Danny Yoo
On Tue, Oct 27, 2015 at 2:32 PM, jarod_v6--- via Tutor wrote: > Hi! > I want to reads two files and create simple dictionary. Input file contain > more than 1 rows > > diz5 = {} > with open("tmp1.txt") as p: > for i in p: > lines = i.rstrip("\n").split("\t") > diz5.setde

Re: [Tutor] How to parse large files

2015-10-27 Thread Danny Yoo
> Instead of doing: > > diz5 = {} > ... > > we'd do something like this: > > with diz5 = dbm.open('diz5, 'c'): Sorry, I'm getting my syntax completely wrong here. My apologies. This should be: with dbm.open('diz5', 'c') as diz5: ... Apologies: I just got back from work

Re: [Tutor] For Loop

2015-10-30 Thread Danny Yoo
On Fri, Oct 30, 2015 at 10:48 AM, Martin A. Brown wrote: > > Hello Shelby, > >> I was wondering if someone can complete a for loop in an array for >> me. > > Your question is a bit too terse. You don't give us too much detail > in understanding what you want to do. Also, we have no idea *why* y

Re: [Tutor] How to parse large files

2015-11-01 Thread Danny Yoo
> AttributeErrorTraceback (most recent call last) > in () > > 1 with shelve.open("diz5") as db: > 2 with open("tmp1.txt") as instream: > 3 for line in instream: > 4 assert line.count("\t") == 1 > 5 key, _ta

Re: [Tutor] How to parse large files

2015-11-01 Thread Danny Yoo
On Sun, Nov 1, 2015 at 5:17 PM, Peter Otten <__pete...@web.de> wrote: > jarod_v6--- via Tutor wrote: > >> Thanks!! >> I use python2.7 Can Also use in that version? > > Yes. Hi Jarod, Also for reference, here are the equivalent 2.7 doc links: https://docs.python.org/2/reference/compound_stm

Re: [Tutor] Tutor Digest, Vol 141, Issue 11

2015-11-11 Thread Danny Yoo
On Wed, Nov 11, 2015 at 4:18 AM, Burhan ul haq wrote: > Continuing "Run Python 2.7 on Android Tablet" > > Hi, > > I am constrained to install anything on my official laptop, therefore I > need to have an "online life saver" for Python Learning. You might look into repl.it: https://repl.it/l

Re: [Tutor] Tutor Digest, Vol 141, Issue 11

2015-11-11 Thread Danny Yoo
>> I am constrained to install anything on my official laptop, therefore I >> need to have an "online life saver" for Python Learning. > > > You might look into repl.it: > > https://repl.it/languages/python As for tutorial material, you might look into: https://wiki.python.org/moin/Begi

Re: [Tutor] os.popen - using commands and input %

2015-11-17 Thread Danny Yoo
On Mon, Nov 16, 2015 at 4:17 AM, Vusa Moyo wrote: > Hi Guys, > > My code is as follows > > # this list contains system process ID's > pidst=[1232, 4543, 12009] > > pmap_str=[] > command="pmap -d %s | grep private |awk '{print $1}' | awk -FK '{print $1}'" > > for i in range(len(pids)): > pmap_s

Re: [Tutor] Modulus Operator ?

2015-11-19 Thread Danny Yoo
On Thu, Nov 19, 2015 at 1:11 PM, Ken Hammer wrote: > y = 49%13 > print y > 10 Actually, let me pretend for a moment that I don't know what the modulus operator is. Why do we get 10 here? Can you verbalize the reason? Can you modify this example above to use the modulus operator with "10" on

Re: [Tutor] Modulus Operator ?

2015-11-20 Thread Danny Yoo
>>On Thu, Nov 19, 2015 at 1:11 PM, Ken Hammer wrote: > >>> y = 49%13 >>> print y >>> 10 > >>Actually, let me pretend for a moment that I don't know what the modulus >>operator is. Why do we get 10 here? Can you verbalize the reason? > > 49 contains 13 3 times and leaves 10 to be divided. > > >>C

Re: [Tutor] Object oriented design

2015-12-20 Thread Danny Yoo
On Sat, Dec 19, 2015 at 4:48 PM, jamie hu wrote: >I am starting with Python object oriented concepts and have difficulty in >understanding object instantiation. Below is an example code that I am >trying to think/implement. I can create a given student object based on >given firstn

<    9   10   11   12   13   14   15   16   17   18   >