Re: [Tutor] get key value from Redis instance

2018-05-27 Thread Danny Yoo
One other recommendation: remove the try/except block for now. Don't use exception handling. We want to use exception handling if we have any significant recovery logic, or if it's important not to expose program errors to the end user. But your situation doesn't match this. In fact, you want to

Re: [Tutor] get key value from Redis instance

2018-05-27 Thread Danny Yoo
> From a first glance: it looks like one of your print statements is not > vertically aligned with the rest of your print statements, so I would > expect Python to be reporting a SyntaxError because of this misalignment. Substitute the word "vertical" with "horizontal". Sorry: I made yet anoth

Re: [Tutor] get key value from Redis instance

2018-05-27 Thread Danny Yoo
On Sun, May 27, 2018 at 3:02 PM Silviu Chiric wrote: > Dear all > I need to get the value of given key from Redis, or both key and value, the > below code snippet fails always, even the connection is okay What is the error you see? Please also include the error message, verbatim. Computer sys

Re: [Tutor] Storing passwords and version control

2018-05-27 Thread Danny Yoo
The recommendations in https://stackoverflow.com/questions/7014953/i-need-to-securely-store-a-username-and-password-in-python-what-are-my-options might apply. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://m

Re: [Tutor] Nested use of replication operator on lists

2018-05-24 Thread Danny Yoo
Each value in Python has an associated numeric address associated to it. We can probe for it: https://docs.python.org/3/library/functions.html#id For example: # >>> x = [1, 2, 3] >>> y = x[:] >>> id(x) 139718082542336 >>> id(y) 139718082556776 ##

Re: [Tutor] Need help with FileNotFoundError

2018-04-26 Thread Danny Yoo
> copy('~/Documents/Courses/ModernBootcamp/story.txt', > '~/Documents/Courses/ModernBootcamp/story_copy.txt') Hi Jim, You may need to use os.path.expanduser, as "tilde expansion" isn't something that's done automatically. This is referenced in the docs when they say: "Unlike a unix shell, Pytho

Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-24 Thread Danny Yoo
> Please consider this situation : > Each line in "massive_input.txt" need to be churned by the > "time_intensive_stuff" function, so I am trying to background it. > > import threading > > def time_intensive_stuff(arg): ># some code, some_conditional >return (some_conditional) > > with open

Re: [Tutor] Recommended Python Compiler

2017-07-30 Thread Danny Yoo
On Sun, Jul 30, 2017 at 3:22 PM, George Sconyers via Tutor wrote: > Hello all. I am getting started with Python and looking for a recommended > compiler for an Ubuntu environment. I've been using gedit but don't get the > benefit of auto-indentation and color coding of key words. It is laziness

Re: [Tutor] Python3 Help

2017-07-23 Thread Danny Yoo
> 2. I’m trying to locate the directory path to where Python3 is located on my > system, but when I enter > the following command: > $ type -a python3 > > I get: > -bash: $: command not found Ah. Do not include the leading "$" in the command that you're typing.

Re: [Tutor] class newbie

2017-07-23 Thread Danny Yoo
On Sun, Jul 23, 2017 at 1:24 PM, Michael C wrote: > class mahschool: > def print(): > print('Say something') By the way, you've chosen a name for your method that's spelled the same as the name of the built-in "print" function. I'd recommend you choose a different name than "print"

Re: [Tutor] Quick Pythonic Style Tips

2017-07-22 Thread Danny Yoo
> I'd like to contibute a rather different sort of tidbit to what Alan > wrote: be really careful about using mutable data types in function > calls, as class variables, and just in general. By the way, there are some tools known as "linters" that can help catch these kind of errors. https://www.

Re: [Tutor] Why use main() ?

2017-07-05 Thread Danny Yoo
In most cases, my scripts tend to be pretty self-contained and written for my own purposes, so that would rarely be an issue. How would you hide main() if you _were_ concerned about it? The "main" option would be to move the body of main() to a separate file, which imports the original file as

Re: [Tutor] Why use main() ?

2017-07-05 Thread Danny Yoo
>> I personally find using main() cumbersome, but many examples I come >> across use main(). Is there some fundamental benefit to using main() >> that I'm missing? > > In no particular order: testing, encapsulation, and reusability. With > a "main()" function (which, recall, can be named whatever

Re: [Tutor] dictionaries are same but returning false

2017-07-05 Thread Danny Yoo
The difflib library (https://docs.python.org/2/library/difflib.html) can also help with some exploratory discovery of the problem. Here's an example: >>> import difflib >>> for line in difflib.context_diff(repr(x).split(','), repr(y).split(','

Re: [Tutor] how-to generate specific lines of text from two python lists

2017-06-25 Thread Danny Yoo
On Jun 25, 2017 12:05 PM, "Danny Yoo" wrote: As the other tutors have suggested, look into doing the SQL updates directly, rather than format strings of SQL commands. Ah, here's a good resource: http://bobby-tables.com Just to emphasize: the reason I'm pointing t

Re: [Tutor] how-to generate specific lines of text from two python lists

2017-06-25 Thread Danny Yoo
As the other tutors have suggested, look into doing the SQL updates directly, rather than format strings of SQL commands. A major reason is because strings do not natively support the representation of nested, grammatical things like sentences or SQL commands. It's really easy to write a string f

Re: [Tutor] Huge list comprehension

2017-06-12 Thread Danny Yoo
On Sun, Jun 11, 2017 at 9:54 PM, syed zaidi wrote: > Thanks > One reason fornsharing the code was that I have to manually create over 100 > variables Don't do that. Anytime you have to manually repeat things over and over is a sign that you need a loop structure of some sort. Let's look at

Re: [Tutor] New blog that has solution for python programs

2017-06-02 Thread Danny Yoo
Steven says: >> I don't think "what the authors might want" is the only factor here. >> Personally, I think these programming challenge sites probably do more >> harm than good, discouraging people that they're not good enough to be a >> programmer because they can't solve the (often exceedingly t

Re: [Tutor] New blog that has solution for python programs

2017-06-02 Thread Danny Yoo
Legality is the lowest of bars. We should aim higher. I'm pretty sure that the listed sites should strongly prefer *not* to have solutions available like this. The more I think about this, the more I'm tending to say: don't do this. It may feel like charity, but the authors of the problem sets

Re: [Tutor] New blog that has solution for python programs

2017-06-02 Thread Danny Yoo
I'm not a fan of the idea of publishing solutions of coding challenge problems because it often violates the honor codes of institutions. Even if some sites are okay with this, the majority probably are not. Rather than muddy the water, might be best to skirt the issue. What is the problem you're

Re: [Tutor] bracket issue

2017-04-17 Thread Danny Yoo
> coming to recursion well i currently use eval() so everything ok i don't > have to worry about brackets but i want to write my own parser. a top down > parser for expressions. Do *not* use eval to parse expressions. It is an extremely bad idea to do this. Instead, you can use ast.parse, whic

Re: [Tutor] Need help with code

2017-04-17 Thread Danny Yoo
On Mon, Apr 17, 2017 at 12:00 AM, Alan Gauld via Tutor wrote: > On 16/04/17 18:26, Tyler Seacrist wrote: > >> I need to draw a stack diagram for print_n >> called with s = 'Hello' and n=2 and am unsure of how to do so. Are you referring to this? http://www.greenteapress.com/thinkpython/html/thi

Re: [Tutor] How to get url call back from the browser

2017-03-01 Thread Danny Yoo
Hi Palanikumar, It looks like you're using Python 2, since you're referring to SimpleHTTPServer. But you probably do not want to use SimpleHTTPRequestHandler: it's a local file system server. The docs at https://docs.python.org/2/library/simplehttpserver.html#SimpleHTTPServer.SimpleHTTPRequestH

Re: [Tutor] feedback on simple python code

2017-02-27 Thread Danny Yoo
Hi Ryan, Let's take a look... Overloading the "write" method to take in different types of arguments looks a bit suspicious. You have a superclass that defines a write method, and you have two subclasses that implement that method. However, your first implementation, LogFile.write, appears to

Re: [Tutor] Wedscraping Yahoo API

2017-02-20 Thread Danny Yoo
Hi Joe, On Mon, Feb 20, 2017 at 6:32 AM, Joe via Tutor wrote: > Hi, > I keep getting the following error as I am new to programming and I am > following a tutorial and I am using Python 3.6. Can you please point me in > the right direction as to what I am doing wrong. You have made an assump

Re: [Tutor] Q about .join() Thanks!

2017-02-13 Thread Danny Yoo
> That's because dictionaries are not stored sequentially and the > order of retrieval is not guaranteed - it can even change > during the execution of a program so you should never > depend on it. That's because dictionaries are optimised > for random access via the keys not to be iterated over.

Re: [Tutor] Find (list) strings in large textfile

2017-02-11 Thread Danny Yoo
Believe it or not, a change in two characters should make this even faster. :) Change the line: file_list = [i[:-1] for i in my_list.readlines()] to: file_list = {i[:-1] for i in my_list.readlines()} The change is to use a "set comprehension" instead of a "list comprehension". Sets

Re: [Tutor] Find (list) strings in large textfile

2017-02-09 Thread Danny Yoo
Files don't rewind automatically, so once a loop goes through the file once, subsequent attempts will finish immediately. We might fix this by "seek", which will let us rewind files. However, your data is large enough that you might want to consider efficiency too. The nested loop approach is go

Re: [Tutor] Another way to strip?

2017-01-19 Thread Danny Yoo
On Jan 19, 2017 4:36 PM, "ad^2" wrote: Hello all, I'm looking for a cleaner more elegant way to achieve stripping out a file name from a list which contains a path and file extension. Would os.path.split help here? https://docs.python.org/3.6/library/os.path.html#os.path.split ___

Re: [Tutor] How to interact with the result of subprocess.call()

2016-12-24 Thread Danny Yoo
On Sat, Dec 24, 2016 at 2:40 PM, Jim Byrnes wrote: > subprocess.call(['libreoffice', '/home/jfb/test.ods']) > k.tap_key(k.enter_key) > k.tap_key(k.enter_key) > > If I run the above code, libreoffice opens the test.ods spreadsheet then > just sits there. When I close libreoffice the two enter_keys

Re: [Tutor] function argument unpacking

2016-12-08 Thread Danny Yoo
On Thu, Dec 8, 2016 at 1:11 AM, Alan Gauld via Tutor wrote: > On 08/12/16 06:04, Palanikumar wrote: >> #Function Argument unpacking >> def myfunc(x, y, z): >> print(x. v. z) >> > > Please always send the actual code that generates > the error, do not retype as it causes us to chase > phantom

Re: [Tutor] Regex ^$ not behaving as expected

2016-12-08 Thread Danny Yoo
Following up: drats! Detecting this conceptual TypeError is not feasible under the current design, due to the choice of data representation used in this API. The reason is because the flags are being represented as integers, and we're using bitwise operations to define the union of flags. That i

Re: [Tutor] Regex ^$ not behaving as expected

2016-12-08 Thread Danny Yoo
> I'm still somewhat confused as to what the regexp module is doing when > passing a non-numeric count parameter. That looks like it should > raise a TypeError to me, so perhaps someone needs to file a bug > against the standard library? Unsure. Ok, I'm filing a bug to the Python developers so

Re: [Tutor] Regex ^$ not behaving as expected

2016-12-08 Thread Danny Yoo
Hi Edmund, For each of the cases that surprise you, next time, can you also say what you expected to see? That can help us see where the confusion lies; as it stands, if we have the same mental model as what's happening in Python, then the results look correct to us. :P I can guess at what you

Re: [Tutor] Q regarding external program calling

2016-11-05 Thread Danny Yoo
Hi Clayton, I'm not too familiar with development on Windows, unfortunately, but I think the 'subprocess' module is what you're looking for. https://docs.python.org/3/library/subprocess.html For example: http://stackoverflow.com/questions/748028/how-to-get-output-of-exe-in-python-script sh

Re: [Tutor] Python code

2016-11-01 Thread Danny Yoo
On Nov 1, 2016 4:57 PM, "Haley Sandherr" wrote: > > Hello, I am new to python and need help with this question: > > Compose a function odd ( ) that takes three bool arguments and returns True if an odd number of arguments are True and False otherwise. Do you understand all of the terms in the que

Re: [Tutor] comp.lang.python on gmane

2016-10-28 Thread Danny Yoo
Ah. The wiki link does point to the expected place after all. I think, then, that the initial assessment is accurate, that Gmane is still recovering their archives, and that eventually the link will work again. ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] comp.lang.python on gmane

2016-10-28 Thread Danny Yoo
>>> >>> Is comp.lang.python available on gmane? >>> >>> I've googled and found references to it being on gmane but I can't find >>> it there. I'd like to use gmane because Comcast doesn't do usenet >>> anymore. >> >> >> I don't know about the current viability of gmane in general, but it's >> calle

Re: [Tutor] New to Python

2016-10-27 Thread Danny Yoo
> program-they just do it. Also noticed-when starting new file sometimes I > see run at the top sometimes not? Lots of questions. Familiar with > programming in C. If you're a database and C developer, then you probably have enough experience to go through the Python tutorial, as it is aimed for

Re: [Tutor] comp.lang.python on gmane

2016-10-27 Thread Danny Yoo
On Thu, Oct 27, 2016 at 5:40 PM, Jim Byrnes wrote: > Is comp.lang.python available on gmane? > > I've googled and found references to it being on gmane but I can't find it > there. I'd like to use gmane because Comcast doesn't do usenet anymore. Hi Jim, I think Gmane is still recovering: h

Re: [Tutor] a bit off topic.. - more of a high level arch question!

2016-10-21 Thread Danny Yoo
> Thinking of a situation where I have two "processes" running. They > each want to operate on a list of files in the dir on a first come > first operate basis. Once a process finishes with the file, it deletes > it. > > Only one process operates on a file. > > I'm curious for ideas/thoughts. Hi

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Danny Yoo
Please do not give homework solutions. Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing Yahoo with Python?

2016-10-09 Thread Danny Yoo
On Sat, Oct 8, 2016 at 3:29 PM, Jim Byrnes wrote: > I realize that my question is not about the standard library. The only > reason I am asking here is, if I remember correctly, a regular contributor, > Danny Yoo, works at Yahoo. I am hoping he, or someone else here can help me > und

Re: [Tutor] Help regarding reg exp.

2016-10-05 Thread Danny Yoo
> On 05/10/16 10:03, rakesh sharma wrote: >> Hi all >> >> I have a string of pattern ({A,BC},{(A,B),(B,C)(C,A)}. > On Wed, Oct 5, 2016 at 3:14 AM, Alan Gauld via Tutor wrote: > Until we understand the data better we can't be sure > a regex is the best solution. Yes, I agree with Alan: we need t

Re: [Tutor] differences between map and partial?

2016-09-27 Thread Danny Yoo
On Tue, Sep 27, 2016 at 2:23 AM, source liu wrote: > Hi, List > > the test code as attached Unfortunately, it didn't attach. If you can inline the content of the test code, that would be helpful. > this one works print p.map(partial(file_op,lineop=unity),input) > this one doesn't

Re: [Tutor] python coding problem

2016-09-26 Thread Danny Yoo
Hi Richard, The "return" statement does an early escape out of the currently running function. You have a "return" statement in your program that looks unintentional. In an ideal world, the Python compiler would give a warning about this because it's a common mistake. Unfortunately it looks lik

Re: [Tutor] Problem

2016-08-28 Thread Danny Yoo
On Sun, Aug 28, 2016 at 7:46 AM, shahan khan wrote: > Hello > I'm teching myself Python using MIT opencourse ware. I'm a beginner and > have some what knowledge of c and c++. I'm using Python version > Here is my code: [code cut] Before showing code, try to express what you're trying to do in

Re: [Tutor] data storage question

2016-08-03 Thread Danny Yoo
> Based on both replies I got, JSON is what I will use. > > I do need the keys in the dictionary to be numerals, specifically they are > integers. > > I believe after I load a stored pt_table, I can use this script to convert > the keys back to integers. > > pt_table = dict((int(key), value) for

Re: [Tutor] Problem with code interating thri a list

2016-08-02 Thread Danny Yoo
On Tue, Aug 2, 2016 at 7:59 AM, Chris Clifton via Tutor wrote: > My Logic: Since a string is immutable, I converted it to a list to separate > out the characters and keep them in order. Idea is to change the case of the > characters in the list then run a join to convert it back to a string.

Re: [Tutor] data storage question

2016-08-01 Thread Danny Yoo
One other thing: you might hear another popular approach is to use the "pickle" module. I don't think it'd be appropriate for your situation because it would be overkill for the problem you're describing. JSON is safer: if you have to choose between JSON and pickle, use JSON. --- More curmudgeo

Re: [Tutor] data storage question

2016-08-01 Thread Danny Yoo
I agree with Steven; JSON is probably one of the most popular formats for saving structured data externally, and it's probably the lightweight approach to use in this situation. By the way, it looks like you're already dealing with a certain file format in your program. In fact, it looks like a s

Re: [Tutor] Python Assignment

2016-08-01 Thread Danny Yoo
On Mon, Aug 1, 2016 at 8:18 AM, Justin Korn via Tutor wrote: > To whom it may concern, > I need someone to help me to develop programs for the following assignments. You've asked a few questions earlier: https://mail.python.org/pipermail/tutor/2016-July/109403.html https://mail.python.

Re: [Tutor] Book recommendation

2016-08-01 Thread Danny Yoo
> One area that is especially troublesome is knowledge of > math. Programming is rooted in math and professional > programmers will have studied math in depth but many > amateur beginners may only have junior school math > level. But how do you find out? > > It's a perennial problem when experts tr

Re: [Tutor] python programmin problem

2016-07-27 Thread Danny Yoo
> You will see a problem being explained that you should be *very* > interested in. :) Here's a link just to give you a taste: > > https://youtu.be/0yjebrZXJ9A?t=3m > > > I hope that this helps point you in the right direction. Good luck! He has some more recent videos from 2012: htt

Re: [Tutor] python programmin problem

2016-07-27 Thread Danny Yoo
On Sun, Jul 24, 2016 at 4:30 PM, monik...@netzero.net wrote: > Thank you all for your answers. I do not have a teacher or any body else who > could guide me. I have taken all python classes offered in my area and many > on line. > The question is one of questions asked by interviews for a qa pos

Re: [Tutor] python programmin problem

2016-07-24 Thread Danny Yoo
> You probably want to use a problem that has fewer moving parts. Your instructor likely has a much nicer introductory problem so that you can learn the patterns of thinking through these problems. Just to add: there are online resources you can use for this. Khan Academy, for example: https://w

Re: [Tutor] python programmin problem

2016-07-24 Thread Danny Yoo
On Jul 23, 2016 9:27 AM, "monik...@netzero.net" wrote: > > IM sorry I do not understand: > > For array A of length N, and for an integer k < N: > -- By k do you mean value of k or position of k in the list? > The letter 'k' is typically intended to be used as an index, a position into a list. I'

Re: [Tutor] python programmin problem

2016-07-23 Thread Danny Yoo
On Thu, Jul 21, 2016 at 11:30 PM, Alan Gauld via Tutor wrote: > > Forwarding to list. Please use reply-all when responding to tutor messages. > > As Danny suggested this is quite a complex problem. I wasn't sure whether > it was just the programming or the bigger algorithm issue you were stuck on.

[Tutor] Fwd: Re: Help me out please

2016-07-21 Thread Danny Yoo
Apologies: I don't have time at the moment to answer. Forwarding to the mailing list! -- Forwarded message -- From: "Marc Sànchez Quibus" Date: Jul 21, 2016 12:08 AM Subject: Re: [Tutor] Help me out please To: "Danny Yoo" Cc: Thanks for your fast r

Re: [Tutor] Help me out please

2016-07-20 Thread Danny Yoo
On Tue, Jul 19, 2016 at 4:31 AM, Marc Sànchez Quibus wrote: > Hi, > First of all I'm gonan introduce myself. My name is Marc and I'm a student > and also a python's programmer begginer. I've been studying/learning python > and now I need some help to finish my project. > I have two scripts, one of

Re: [Tutor] python programmin problem

2016-07-20 Thread Danny Yoo
On Wed, Jul 20, 2016 at 2:11 PM, monik...@netzero.net wrote: > Hi: > Can somebody please provide answer to following python programming question? > I have spent days on it and cannot come up with any code that would make any > sense for it so I cannot provide you any code. But I would appreciate

Re: [Tutor] error

2016-07-06 Thread Danny Yoo
> > Have you checked that you have the requisite permissions? That the > socket you are connecting to exists? If its a system call error the > problem is most likely in your environment rather than your code. > That particular error is from Windows. One common cause for it is a network firewall,

Re: [Tutor] decorators -- treat me like i'm 6.. what are they.. why are they?

2016-07-06 Thread Danny Yoo
> As to who suggested them you'd need to go back through the > PEPs to see who first suggested it, and then maybe more to see > who's idea finally got accepted. I think it was in Python 2.5. Hi Bruce, Yes, it happened back around 2003: https://www.python.org/dev/peps/pep-0318/ Decorators

Re: [Tutor] isinstance versus 'is'?

2016-07-05 Thread Danny Yoo
On Tue, Jul 5, 2016 at 12:05 PM, Alex Hall wrote: a = 5 isinstance(a, int) > True a is int > False > > What happened there? Don't these do the same thing? I thought I could use > them interchangeably? 'isinstance' is something else from 'is'. isinstance will tell us if something

Re: [Tutor] iterators

2016-07-04 Thread Danny Yoo
On Mon, Jul 4, 2016 at 1:38 PM, Colby Christensen wrote: > I'm sure this is something simple but I'm missing it. > When I check the statement with two values, the if statement works. However, > for the statement with one value I get an error. > keycode = event.GetKeyCode() > if keycode in (13, 37

Re: [Tutor] error in python code.

2016-06-21 Thread Danny Yoo
> You need to state some definitions so that we are sharing common > terminology. What does "skew" mean, for example? Note to others: I'm guessing that this has something to do with GC skew as described in https://en.wikipedia.org/wiki/GC_skew. But I'd rather not guess. I'd like Riaz to explain

Re: [Tutor] error in python code.

2016-06-21 Thread Danny Yoo
On Sun, Jun 19, 2016 at 10:38 PM, riaz tabassum wrote: > Sir i have a problem to solve to python code. I have attached the pic of > problem statement. Hi Riaz, Often when you're asking a question, starting with presentation of the code is often the wrong order to attack a problem. The reason

Re: [Tutor] Why are expressions not allowed as parameters in function definition statements?

2016-06-18 Thread Danny Yoo
One other thing to add: the notion of pattern matching is often used in mathematics. For example, if we want to define a function that does something special to even numbers vs. odd numbers, it's not uncommon to see the following when we want to describe a function `f`: for `n` in the natural num

Re: [Tutor] Why are expressions not allowed as parameters in function definition statements?

2016-06-18 Thread Danny Yoo
> You know Steve, as I was typing the beginning of a reply responding to > a similar question you asked earlier in your response, I suddenly > realized how ridiculous having a parameter of 'col/2' is! I'll just > have either eat crow or attribute this to a brain fart. You pick! Just to play dev

Re: [Tutor] Baffling problem with a list of objects sharing a property

2016-05-26 Thread Danny Yoo
> They are. You've stiumbled on one of those Python peculiarities of > implementation that can be useful and annoying in equal measure. > >> class Test(object): >> def __init__(self, name, paths=[]): >> self.name = name >> self.paths = paths > > When you give a function/method a default value

Re: [Tutor] Getting started in testing

2016-05-19 Thread Danny Yoo
On Thu, May 19, 2016 at 12:34 PM, Terry Carroll wrote: > Is anyone aware of any good tutorials on testing one's Python code? > > These days, I'm a hobby programmer, writing little things just for my own > use, and don't really sweat testing much. But I do have one niche > open-source project where

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Danny Yoo
On Tue, May 10, 2016 at 10:37 PM, nitin chandra wrote: > Thank you Danny, Alan, > > @ Danny > > I added 'str(formt(line1[0]))' will this do ? Unfortunately, I don't know: what makes me hesitant is the following: * The above is doing something just to line1[0], which looks odd. Why just li

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Danny Yoo
> here is the result. > > 1 > ('Supervisor',) > > 1 > Vinayak > Salunke > 1 > > Now I need to remove the braces and quotes .. :) By the way, be very careful about generating HTML via naive string concatenation. If you can use a template engine such as Jinja (http://jinja.pocoo.org/), please do

Re: [Tutor] Best Practices with JSON Data

2016-05-08 Thread Danny Yoo
On Sun, May 8, 2016 at 6:07 AM, Hunter Jozwiak wrote: > Hello, > > > > I am intending to start work on a Python program that will allow me to > better manage my Digital Ocean droplets It sounds like you're using the DigitalOcean API described in https://developers.digitalocean.com/documentation/v

Re: [Tutor] Python Homework

2016-05-02 Thread Danny Yoo
On Sun, May 1, 2016 at 1:47 AM, Ben Finney wrote: > Katie Tuite writes: > > You'll need to write only plain text email (no attached documents, no > “rich text”) for the information to survive correctly. This is always > good practice for any technical discussion forum. Hi Katie, Also, try to pr

Re: [Tutor] simple regex question

2016-05-02 Thread Danny Yoo
On Sun, May 1, 2016 at 9:49 AM, bruce wrote: > I've created a test regex. However, after spending time/google.. can't > quite figure out how to then get the "complete" line containing the > returned regex/pattern. > > Pretty sure this is simple, and i'm just missing something. A few people have

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Danny Yoo
On Tue, Apr 26, 2016 at 3:43 PM, Kanika Murarka wrote: > The folder which we create using command > $ Virtualenv venv Hi Kanika, I think you need to ask the virtualenv folks; it seems to be virtualenv-specific. Their forum is: https://groups.google.com/forum/#!forum/python-virtualenv Go

Re: [Tutor] def __init__(self):

2016-04-26 Thread Danny Yoo
On Tue, Apr 26, 2016 at 2:32 AM, Santanu Jena wrote: > Hi Oliver. > I have idea regarding " __init__" method/ class.but still I have confusion > on "def __init__(self): " Please share your under standing. A big point of an entry point, conceptually, is to establish properties that we'd like to

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Danny Yoo
On Tue, Apr 26, 2016 at 6:47 AM, Kanika Murarka wrote: > Hi, > I want to detect whether a 'file1.py' belongs to virtual environment > folder( generally 'venv') or not ( considering different people may have > different names for virtual environment folder.). I think we need more information on w

Re: [Tutor] The game of nim in python

2016-04-22 Thread Danny Yoo
On Fri, Apr 22, 2016 at 5:45 AM, Henderson, Kevin (GE Aviation, US) wrote: > Python to Jython. > > Can you help me with a Jython code for the Nim game? If you can say more about what you're like help with, we can tailor advice toward what you want. I'll treat this as a quick-and-dirty design rev

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
Sorry for typos in response: on cell phone at the moment. ;p ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
Okay, in the context of a function, the error you're seeing makes more sense. You need to ensure that the return value of the function is of the right type. In SingleView, the intended return value appears to be a structured response value. Given that, then any other return statements in the bo

Re: [Tutor] Slack Token Invalid Syntax

2016-04-19 Thread Danny Yoo
On Tue, Apr 19, 2016 at 10:05 AM, Malcolm Boone wrote: > So you are saying the right side should be a string, how do I do that? See: https://docs.python.org/3/tutorial/introduction.html#strings > When I put quotes around the token it creates a dozen or so new errors. > Unless > I'm not e

Re: [Tutor] List of tuples

2016-04-19 Thread Danny Yoo
On Tue, Apr 19, 2016 at 1:56 PM, isaac tetteh wrote: > I have a list like this > [ > ("name",2344,34, "boy"),("another",345,47,"boy", "last") > ] > How do u get each value from it like > Output > name > 2344 > 34 > ... > > What i did was > for row in list_tuple: > for row2 in row: > re

Re: [Tutor] (no subject)

2016-04-18 Thread Danny Yoo
On Mon, Apr 18, 2016 at 9:52 AM, Halema wrote: > Hello, > I have a project and need someone to help below you will see details about it > , please if you able to help email me as soon as possible and how much will > cost ! You might not realize this, but what you're asking is a violation of mo

Re: [Tutor] ImportError: No module named...

2016-04-17 Thread Danny Yoo
> But I get the following error code on line 1 > > ImportError: No module named pdfgen > Is reportlab.pdfgen a standard part of that package's installation? You might want to check for possible conflicts with other things called reportlab. Do you have any files in the current directory that are

Re: [Tutor] (no subject)

2016-04-16 Thread Danny Yoo
On Wed, Apr 13, 2016 at 12:15 PM, Eben Stockman wrote: > could you please help because it is really important as it counts towards my > Gcse Just to add: please try to avoid saying this detail in the future. It's much more helpful to talk about what you've tried, what parts you understand, and

Re: [Tutor] operations on lists

2016-04-16 Thread Danny Yoo
On Wed, Apr 13, 2016 at 12:41 PM, marcus lütolf wrote: > Hello experts > > I'am working exercise 5. of 'Practical Programming 2nd edition, .using > Python 3' (operations on lists). > The following code get's me wrong results: > metals = [['beryllium', 4],['magnesium', 12], ['calcium', 2

Re: [Tutor] Understanding error in recursive function

2016-04-08 Thread Danny Yoo
On Fri, Apr 8, 2016 at 1:48 PM, Tom Maher wrote: > Hi, > > As a test I am trying to write a function that returns the sum of values > attached to one key in a dictionary. Why does the program try to use recursion for this problem? ___ Tutor maillist -

Re: [Tutor] Fw: About the Round Function

2016-04-02 Thread Danny Yoo
On Fri, Apr 1, 2016 at 6:13 PM, Ben Finney wrote: > Nacir Bouali writes: > >> My students and I are interested in knowing the rationale behind >> Python's choice of the Banker's rounding algorithm to be the default >> rounding algorithm in the third release of Python. > > Can you provide a link t

Re: [Tutor] Fw: About the Round Function

2016-04-01 Thread Danny Yoo
>My students and I are interested in knowing the rationale behind Python's >choice of the Banker's rounding algorithm to be the default rounding >algorithm in the third release of Python. To be specific: your question is on the toplevel round() function. https://docs.python.org/3/

Re: [Tutor] Week 10 warmup assignment

2016-04-01 Thread Danny Yoo
Hi Daniella, Your class is using an additional tool called 'pylint' which enforces certain style conventions. One of those conventions that Pylint is checking is that variables as arguments aren't supposed to be all in upper case. Upper case is a convention for constants, and a variable is not a

Re: [Tutor] How python keeps track of data types

2016-03-29 Thread Danny Yoo
Hi Abhishek, On Mon, Mar 28, 2016 at 12:31 PM, Abhishek Kumar wrote: > Hello > I am a computer science student,I want to know how python keeps track of > data types of variables and is there a way to get data types of variables > without actually running the script(with type() function). I think

Re: [Tutor] OT: (Continuous) integration testing: Can a solo developer with very limited resources truly do this?

2016-03-12 Thread Danny Yoo
On Sat, Mar 12, 2016 at 10:10 AM, boB Stepp wrote: > From "Practices of an Agile Developer" by Venkat Subramaniam and Andy > Hunt, c. 2006, page 90: > > > You're already writing unit tests to exercise your code. Whenever you > modify or refactor your code, you exercise your test cases before you

Re: [Tutor] How to compare dates which has (,)

2016-03-10 Thread Danny Yoo
> but I am not understanding how do i capture and compare dates in bellow > formate (,) : > Do you know the name or structure of the format that you're seeing here? I would assume BRT represents some timezone, but I am not sure. Let me check... http://www.timeanddate.com/time/zones/brt OK, so

Re: [Tutor] FASTA FILE SUB-SEQUENCE EXTRACTION

2016-03-08 Thread Danny Yoo
You should probably look into Biopython: http://biopython.org/wiki/Main_Page Your question should involve fairly straightforward use of the Seq methods of Biopython. You should not try to write your own FASTA parser: Biopython comes with a good one already. Note that the tutor mailing list is

Re: [Tutor] recursivity and lists

2016-03-05 Thread Danny Yoo
On Mar 5, 2016 5:56 AM, "Robert Nanney" wrote: > > Would this meet the requirements? It's doing a sort, but not in a merging way. Merge sort takes advantage of a property of the input lists: the input lists are known to be already sorted. The general sort routine for lists doesn't take much adv

Re: [Tutor] recursivity and lists

2016-03-04 Thread Danny Yoo
> As we can see, we have to do a lot more consideration of what state > our values are in, due to all the mutation happening. It also shows > that the second recursive call to the linear_merge() is not really > using it to merge: it's really trying to select the list that was used > to accumulate

Re: [Tutor] recursivity and lists

2016-03-04 Thread Danny Yoo
> Both work but I am not satisfied. Is there not a method that could do the job > of '+' operator (namely concatenate in a copy)? > No; unfortunately Python doesn't make functional approaches as convenient as I would personally like. The copy operation on lists itself is expensive to do, so tha

Re: [Tutor] recursivity and lists

2016-03-03 Thread Danny Yoo
Some code comments: The solution you have depends very much on mutation and side effects: I recommend you try to stay as functional as you can in this situation. By mixing mutation into the solution, there are certain things that the program is doing that isn't part of the traditional behavior of

  1   2   3   4   5   6   7   8   9   10   >