Re: [Tutor] How to list/process files with identical character strings

2014-06-24 Thread Danny Yoo
The sorting approach sounds reasonable. We might even couple it with itertools.groupby() to get the consecutive grouping done for us. https://docs.python.org/2/library/itertools.html#itertools.groupby For example, the following demonstrates that there's a lot that the library will do for us

Re: [Tutor] learning to programming questions part 1

2014-06-24 Thread Danny Yoo
On Jun 24, 2014 4:55 PM, "keith papa" wrote: > > 1. Hi am new to python and I have a few questions: > Why if you want to write multiple comment you use triple quotation marks and not the #? > In certain places, string literals are treated as documentation that you can access with the help() funct

Re: [Tutor] learning to programming questions part 1

2014-06-24 Thread Danny Yoo
> In certain places, string literals are treated as documentation that you can access with the help() function. Triple quotes are a way of writing a strong literal. Sorry! "strong" should be "string". ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] What are your favourite unofficial resources

2014-06-30 Thread Danny Yoo
>> What are the best unofficial (ie not python.org) >> resources for people who have learned the basics >> but are not experts yet? > > dejanews.com, no wait, that's now groups.google.com -- oh wait, the > just-don't-be-evil empire kinda killed that one off finally. >sigh< Hi Emile, I do not k

Re: [Tutor] What are your favourite unofficial resources

2014-06-30 Thread Danny Yoo
On Mon, Jun 30, 2014 at 4:01 PM, Emile van Sebille wrote: > On 6/30/2014 3:48 PM, Danny Yoo wrote: >>>> >>>> What are the best unofficial (ie not python.org) >>>> resources for people who have learned the basics >>>> but are not experts

Re: [Tutor] server / client program

2014-06-30 Thread Danny Yoo
On Mon, Jun 30, 2014 at 5:12 PM, Ant Parris wrote: > Hi, I am new to python and i am stuck on a lab I am working on. below is the > lab instructions for creating a server and client program. > > 1) Both server and client program run continually > 2) until no message is coming in the server. It mea

Re: [Tutor] What are your favourite unofficial resources

2014-07-01 Thread Danny Yoo
Yikes, I completely forgot about Dive Into Python! http://www.diveintopython.net/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why is Quick Search at docs.Python.org so useless?

2014-07-05 Thread Danny Yoo
> I realize that this list doesn't have control over python.org, but there are enough of you who are experts about all this stuff that maybe some changes can be made. If I ever learn enough, I hope to be part of the solution myself. A working search engine would be most helpful. Hi Deb, Yeah, u

Re: [Tutor] Why is Quick Search at docs.Python.org so useless?

2014-07-06 Thread Danny Yoo
Let's summarize. As it stands, this really is out of our direct control, as Deb mentions. The actions we can do seems to be: 1. To point folks to alternative search engines that are effective in searching through Python documentation. 2. Direct feedback to the Python web site maintainers

Re: [Tutor] A beginner having problems with inheritance

2014-07-06 Thread Danny Yoo
> My apologies to the tutors. > I have identified my error, which was predictably elementary. > With many thanks, By the way, can you say what your conceptual error was or give an example? It might help the other folks here who are learning and who may be making a similar mistake. (And I'm curi

Re: [Tutor] Python Socket Error: Connection refused

2014-07-06 Thread Danny Yoo
> I need some help, I have no programming skills and am trying to teach myself > python. I keep on getting an error message as follows: [content cut] It appears from the screenshot that you are running some version of Windows that has software that's interfering with IDLE. As the error message

Re: [Tutor] SyntaxError Message

2014-07-08 Thread Danny Yoo
> I have no programming experience and am trying to teaching myself python. > Am trying to replicate the code below but I get the error message below > highlighted in yellow: We need a little more information. Where does this code come from? What text book or instructional material are you usin

Re: [Tutor] SyntaxError Message

2014-07-08 Thread Danny Yoo
Following up. I can guess that you're looking at: http://www.sthurlow.com/python/lesson05/ But I would like not to guess unless I have no choice. In the future, if you're asking for help, provide context. The reason why it's very useful to say where you're learning from is because we can th

Re: [Tutor] Next steps...

2014-07-08 Thread Danny Yoo
On Mon, Jul 7, 2014 at 8:51 PM, Ni Hung wrote: > ok, I am now able to write scripts in python. I can read/modify scripts > written by others (true to some level). I understand the basics of > libraries (how are they different from modules or are the same thing with > two names?) like urllib2, js

Re: [Tutor] How can I open and use gnome-terminal from a Python script?

2014-07-08 Thread Danny Yoo
You might look at: http://askubuntu.com/questions/351582/open-terminal-window-and-execute-python-script-on-startup http://superuser.com/questions/198015/open-gnome-terminal-programmatically-and-execute-commands-after-bashrc-was-execu both which appears relevant to your question. If I u

Re: [Tutor] A beginner having problems with inheritance

2014-07-09 Thread Danny Yoo
> My error was simply that I inadvertently used the same name for a method > (function) in the derived class that I had already used in the parent class. > The result was then a very obscure error because the wrong calculation was > performed and later on an array was empty. > Fortunately, thanks t

Re: [Tutor] How does this work (iterating over a function)?

2014-07-09 Thread Danny Yoo
By the way, it may be really instructive to read the article when generators were officially introduced into Python 2.2: https://docs.python.org/3/whatsnew/2.2.html#pep-255-simple-generators It's written for the perspective of someone who doesn't know what generators are. Because of that, it

Re: [Tutor] How does this work (iterating over a function)?

2014-07-09 Thread Danny Yoo
It might also be useful to see what an equivalent version of that fib() iterator looks like if we don't take advantage of generators ourselves. Here's an attempt at it: ### def fib1(max): a, b, = 0, 1 while a < max: yield a a, b,

Re: [Tutor] Off topic - Ruby similar list?

2014-07-09 Thread Danny Yoo
On Wed, Jul 9, 2014 at 3:40 PM, Mike Nickey wrote: > Just curious if there's a similar list like this one for Ruby-ists. > Anyone know of one or two? Hi Mike, I believe the general ruby-talk mailing list is what you're looking for. See: https://www.ruby-lang.org/en/community/mailing-lists

Re: [Tutor] sometimes I feel like my head is going to explode

2014-07-10 Thread Danny Yoo
On Thu, Jul 10, 2014 at 3:35 PM, Deb Wyatt wrote: > The more I learn, the more I realize that there is so much more to learn, and > the more difficult some of the stuff to learn seems to be. I'm not sure that > I would have set out on this journey to learn Python if I had known how > massive t

Re: [Tutor] sometimes I feel like my head is going to explode

2014-07-10 Thread Danny Yoo
By the way, there was a nice talk from Camille Fournier that might be relevant to you: https://www.youtube.com/watch?v=sc8sc-ELMhA Unfortunately, last time I checked, her presentation cuts off near the end. But the bangbangcon folks did a lot of great work on recording their conference, incl

Re: [Tutor] How to Create Webpage with Python

2014-07-10 Thread Danny Yoo
> For future reference (assuming everything else goes well) how do I procure a more permanent server (i.e. one that doesn't run on my machine so that I can turn it off and still be able to visit my pages)? I'm hearing Apache and so forth being thrown around (I've read up a little on it) but it see

Re: [Tutor] how do I set variables in Python 3.4

2014-07-11 Thread Danny Yoo
> I am supposed to use operand1=2 and operand2=7 > To complete: result= operand1+operand2 etc, but I keep getting invalid syntax > either on the " or operand1. Please help Unfortunately, you've paraphrased the error message enough that we can not reproduce the problem. Since you're emailing on

Re: [Tutor] TypeError: 'int' object is not iterable

2014-07-11 Thread Danny Yoo
Hi Avishek: Look at the subexpression within the line that Python says it thinks the error is close to: min(n1 + n2) That looks strange. Take a look at that subexpression again. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subs

Re: [Tutor] How to Create Webpage with Python

2014-07-12 Thread Danny Yoo
> On Fri, Jul 11, 2014 at 6:21 AM, Danny Yoo wrote: >> The ones I use for my personal and professional use are webfaction.com and >> appengine.google.com. I'm sure others can give more suggestions. > > Both are services used for hosting webapps, not static websites.

Re: [Tutor] How to Create Webpage with Python

2014-07-12 Thread Danny Yoo
Hi Chris, Yikes. I need to say that as, for disclosure: I work at Google. I do not work on the App Engine team, but I need to acknowledge my potential conflict-of-interest, and I apologize for not stating this in my reply. ___ Tutor maillist - Tutor@

Re: [Tutor] Image Upload FalconFramework

2014-07-12 Thread Danny Yoo
On Tue, Jul 1, 2014 at 8:51 PM, Peter Romfeld wrote: > Hi, > > I try to make a simple image upload function, in django i just used: > > for feature phones: > file = request.body > > rest: > file = request.FILES['image'].read() > > with falcon i tried but not working > req.stream.read() > > Their F

Re: [Tutor] how do I set variables in Python 3.4

2014-07-13 Thread Danny Yoo
On Sun, Jul 13, 2014 at 12:25 AM, Danielle Salaz wrote: > This is what I've been doing, also I'm using version 3.4 > > set "(operand1 = 2 and operand2 = 7) > print (operand1 = 2) > print (operand2 = 7) > print (result=operand1 + operand2) > print (result=operand2 - operand1) > print (result=operan

Re: [Tutor] R: Tutor Digest, Vol 125, Issue 49

2014-07-16 Thread Danny Yoo
Hi Jarod, Ah. Note the extra space on the first column elements. For example, one of your inputs that you've split on tabs: ['uc011lyh.1 ', 'uc003jvb.2'] If you look really closely, you'll see the whitespace at the end of "uc011lyh.1". That's why the regex isn't matching. Good luck!

Re: [Tutor] R: Tutor Digest, Vol 125, Issue 49

2014-07-16 Thread Danny Yoo
By the way, those look like gene locus names. Reminds me of the ones I saw when I worked at arabidopsis.org. e.g.: http://www.arabidopsis.org/servlets/TairObject?id=1000638674&type=gene ___ Tutor maillist - Tutor@python.org To unsubscribe or chang

Re: [Tutor] Surprising behaviour of optional argument

2014-07-17 Thread Danny Yoo
On Jul 17, 2014 10:22 AM, "Jose Amoreira" wrote: > > Hello > I stumbled on something I found surprising. I'm using standard python (cpython, I guess) 2.7 on openSuse 13.1. > > Consider the function > > In [2]: def f(x,y=[]): >...: print y >...: y.append(x) >...: return x >

Re: [Tutor] Modules to work with curl.

2014-07-17 Thread Danny Yoo
On Thu, Jul 17, 2014 at 11:35 AM, Santosh Kumar wrote: > I am currently working on a project , which has lots of curl commands. I am > using subprocess.Popen to run these curl commands. But somehow i see its bit > slow. > Is there a way/module by which i can improve the performance of the program

Re: [Tutor] Modules to work with curl.

2014-07-18 Thread Danny Yoo
On Fri, Jul 18, 2014 at 1:05 PM, Santosh Kumar wrote: > its a curl command caliing a http function. > > for example: > > curl : GET http:///app/somefunction Hi Santosh, Ok, good. This is some of the information that we wanted to know. So you are performing HTTP requests to get content, and yo

Re: [Tutor] Using module Facebook

2014-07-18 Thread Danny Yoo
>>> >>> Now, there's another error message: >>> >>> (facebook)[chris@cd facebook]$ ./fb1.py >>> Traceback (most recent call last): >>> File "./fb1.py", line 6, in >>> import facebook >>> File >>> "/home/chris/software/facebook/lib/python2.6/site-packages/facebook.py", >>> line 811 >>>

Re: [Tutor] Using module Facebook

2014-07-18 Thread Danny Yoo
Hi Chris, Wait. There is one more possibility that I didn't account for: it may be that somehow you haven't installed facebook-sdk, but you may have installed some other package that is providing a facebook.py library. I've was looking more closely at the source code to try to file a bug for yo

Re: [Tutor] Using module Facebook

2014-07-18 Thread Danny Yoo
> I've was looking more closely at the source code to try to file a bug for you: > > https://github.com/pythonforfacebook/facebook-sdk/tree/master/facebook > > but when I look again at the reported error message: > > # > Traceback

Re: [Tutor] how to expand "../../myfile"

2014-07-18 Thread Danny Yoo
On Fri, Jul 18, 2014 at 6:33 PM, Alex Kleider wrote: > Is there a function that can return the full path name when provided with > something along the lines of > "../../myfile"? > > Just to be able to glean the current working directory would suffice. (I > could use a shell command if I had to but

Re: [Tutor] Read, Write, Split and Append lines from a text file

2014-07-19 Thread Danny Yoo
On Sat, Jul 19, 2014 at 2:27 PM, LN A-go-go wrote: > > > I have given it all I got: a week trying to open, read, write, split, append, > convert to integers and then manipulate the data. I have attached the file I > want to pull the names and numbers from. I'll cut and paste it incase that >

Re: [Tutor] Using module Facebook

2014-07-20 Thread Danny Yoo
> I'm not sure, what the error was. I had also installed another facebook > package, not facebook-sdk. Maybe this was the reason. I would upgrade that "maybe" to an "almost certainly". :P You should have mentioned that detail of installing that second facebook library. It's actually crucial to

Re: [Tutor] (no subject)

2014-07-20 Thread Danny Yoo
On Sun, Jul 20, 2014 at 8:40 AM, LN A-go-go wrote: > My apologies Python Gurus for repeating this request for read, write, split > and append from a text file in notepad. I worked on it till late last night > and will again today. I can't seem to get past trying to write the names to > one list

Re: [Tutor] (no subject)

2014-07-20 Thread Danny Yoo
> It also appears that you are trying to write whole programs at the > interpreter loop. This can be inconvenient for larger programs. You > might want to use a text editor or IDE to write the program as a > single file, and then run Python over that program file. See: https://hkn.eecs.berk

Re: [Tutor] Is this possible for a newbie?

2014-07-20 Thread Danny Yoo
>> Am a newbie to programming and I started learning python days ago. I >> have this idea I want to execute, am a big sport and fantasy fan and I >> wanted to create something that will make it things a little easy for >> me. My idea is simple I want to create a program that I can enter name >> and

Re: [Tutor] Getting a directory listing with Python to MySQL

2014-07-22 Thread Danny Yoo
> What I want to do is be able to parse a directory, say /Volumes/Stuff/Files/, and all the directories that might be in there, and be able to pick out file name, size, date modified, etc, Hi Eric, You might find the following helpful: http://www.diveintopython.net/file_handling/os_module.html __

Re: [Tutor] Getting a directory listing with Python to MySQL

2014-07-23 Thread Danny Yoo
On Jul 22, 2014 11:10 PM, "Eric Dannewitz" wrote: > > That's close. I have been playing from glob and os.walk but I'm at a loss how to get the size, creation and modified date while running it. Steven mentioned a few functions in his reply; check those ones out. The 'os' module is a bit large, b

Re: [Tutor] Inquiry

2014-07-24 Thread Danny Yoo
On Jul 24, 2014 3:21 PM, "Allahondoum Mbaibarem" wrote: > > Please I would like to know about the Security and the Reliability of Python. This is somewhat outside the domain of python-tutor discussion. You may want to contact the folks at: http://www.pythonsecurity.org instead. ___

Re: [Tutor] Security and Reliability of Python

2014-07-24 Thread Danny Yoo
> Python is only as secure as the code *you* write. If you write code > where you accept text from untrusted people over the Internet and then > execute it as code using eval() or exec(), then your code is vulnerable > to code injection attacks. The solution to this is simple: don't use > eval() or

Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Danny Yoo
> > but I'm running into a syntax error when running one of the unmodified > > programs. On line 14, which reads: > > > > print("Here", end=" ") > > > > I'm receiving a syntax error which points to the end parameter. I'd like to also support Joel's suggestion to provide detailed output of the err

Re: [Tutor] Python; webcam

2014-08-04 Thread Danny Yoo
On Mon, Aug 4, 2014 at 7:10 AM, René Mathieu wrote: > Hello there > > I'm writing a Python program and I would like to display a video device > (webcam). How should I write in the program? Hi Mathieu René, I'm unsure because I have no direct experience with this. You might want to check the ge

Re: [Tutor] New dealing with Pythong and programming

2014-08-06 Thread Danny Yoo
Hi William, You can take a look at the beginner's guides to Python: https://wiki.python.org/moin/BeginnersGuide If your native language is Spanish, you may want to look at: https://wiki.python.org/moin/SpanishLanguage and see if there are any tutorials there that are easier for you to

[Tutor] Fwd: New dealing with Pythong and programming

2014-08-06 Thread Danny Yoo
en you're asking and answering Tutor-related mail, so that all the helpers there can help. I hope the learning is going well for you! -- Forwarded message -- From: William Vargas Date: Wed, Aug 6, 2014 at 4:09 PM Subject: Re: [Tutor] New dealing with Pythong and programming To: Da

Re: [Tutor] New dealing with Pythong and programming

2014-08-06 Thread Danny Yoo
See if: https://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/IDLE_spanish.html is helpful. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Printing multi-line variables horizontally

2014-08-08 Thread Danny Yoo
On Fri, Aug 8, 2014 at 1:50 AM, Greg Markham wrote: > Hello, > > Python novice back again. :) I'm making progress in my learning process, > but struggling whenever attempting to creatively go beyond what's required > in the various chapter assignments. For example, there's a simple random > die

[Tutor] Pigs can fly?

2014-08-08 Thread Danny Yoo
Hi everyone, I'm curious if anyone has encountered: http://codegolf.stackexchange.com/questions/35623/are-pigs-able-to-fly As soon as I saw this problem, I felt strongly compelled to play with this. :P Of course, I can't show any solutions, but I thought the problem might be interesting to

Re: [Tutor] Error message

2014-08-11 Thread Danny Yoo
Hi Richard, I would recommend asking the PyGame folks on this one. What you're running into is specific to that external library, and folks who work with PyGame have encountered the problem before: they'll know how to diagnose and correct it. For example: http://stackoverflow.com/questions

Re: [Tutor] Exercise to work on

2014-08-12 Thread Danny Yoo
On Tue, Aug 12, 2014 at 1:52 PM, keith papa wrote: > Hi, am a newbie to python and I wondering if you guys can give me some > exercise to work on. I have learned: print function , if function , strings, > variables, and raw_input. The more the better Do you find yourself doing certain kinds of co

Re: [Tutor] read cell phone's directory?

2014-08-14 Thread Danny Yoo
On Wed, Aug 13, 2014 at 7:07 PM, = Clayton - Tang = wrote: > Hi all, > > I am on WIndows and have an Android cell phone running Android 4.4.4. > > When I connect the phone to my PC using a micro-USB cable, the phone appears > next to the local hard drive under "This PC" window, then I can browse t

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > I tested it on IDLE. It works. Hi Sarma, Following up on this one. I'm pretty sure that: print re.search("https://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy for why. ___

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
Hi Sunil, Don't use regular expressions for this task. Use something that knows about HTML structure. As others have noted, the Beautiful Soup or lxml libraries are probably a much better choice here. There are good reasons to avoid regexp for the task you're trying to do. For example, your re

Re: [Tutor] python ssl error

2014-08-17 Thread Danny Yoo
On Sun, Aug 17, 2014 at 5:14 AM, Matthew Ngaha wrote: > Hi this might not be the correct place to ask this. I am using the > google api and as soon as I use the build function: > > service = build('books', 'v1', developerKey=api_key) > > I get an SSL error. I'm not sure what build() does but i

Re: [Tutor] Python = {0}.format

2014-08-17 Thread Danny Yoo
> print("The original quote is: {0}".format(quote)) > print("The new quote is:{0}".format(quote.replace(replaceWord,replaceWith))) Hi Abid, You should be able to change this to the equivalent code: print("The original quote is: " + quote) print("The new quote is:" + quote.replace(replac

Re: [Tutor] how do I make my code better?

2014-08-18 Thread Danny Yoo
Hello, Often, when you're writing code that looks roughly like: ### a_1 = ... a_2 = ... ... a_n = ... if ... a_1: ... if ... a_2: ... ... if ... a_n: ... ### then your program is crying out to use a table. The idea is to use a list to structure th

[Tutor] Embedding resources

2014-08-20 Thread Danny Yoo
On Aug 19, 2014 11:53 PM, "diliup gabadamudalige" wrote: > > Hi all! > > Is there any way I can bundle all my graphics only using Python and Pygame so that the user may not be able to read them out of the program? (Changing subject line to more descriptive title) Would something like http://www.

Re: [Tutor] Fwd: Embedding resources

2014-08-20 Thread Danny Yoo
On Wed, Aug 20, 2014 at 6:45 AM, diliup gabadamudalige wrote: > Hi Danny! > > The routine works fine and so does this one. > > http://www.pygame.org/pcr/zipshow/index.php > > The only problem with all these are that that the time taken to read these > files and to either make a list or send to scr

Re: [Tutor] Parsing txt file

2014-08-20 Thread Danny Yoo
> i need to export to file all stings which start from "Name" > > I've tried to make little parser: > > keywords = ['Name', 'Name:'] > input_file=open("Mail_Groups.txt","r").readlines() > output_file=open("Out.txt","w") > for line in input_file: > for word in line.split(): > if word in

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Danny Yoo
> > lens = [0] * len(catalog2[0]) Ah. Read the following closely: https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list If you have any questions, please feel free to ask further. See if that clears up the mistake that's in your code. ___

Re: [Tutor] Development of administration utility

2014-08-21 Thread Danny Yoo
On Aug 21, 2014 7:39 AM, "Alessandro Di Bella" wrote: > > Hi, > > We are currently investigating different languages and technologies to develop an command line administration utility. Hi Alessandro, This is out of scope for Python Tutor. This is not to say that the question is not interesting,

Re: [Tutor] simple unicode question

2014-08-22 Thread Danny Yoo
On Fri, Aug 22, 2014 at 2:10 PM, Albert-Jan Roskam wrote: > Hi, > > I have data that is either floats or byte strings in utf-8. I need to cast > both to unicode strings. Just to be sure, I'm parsing the problem statement above as: data :== float | utf-8-encoded-byte-string

Re: [Tutor] simple unicode question

2014-08-22 Thread Danny Yoo
Hi Albert, Just following up: I consider the 2 (or 3) arg form of unicode() to be a design flaw in the Standard Library. It's redundant because the bytes type already has a decode() method: https://docs.python.org/3/library/stdtypes.html#bytes.decode So I would personally write convert() l

Re: [Tutor] Using unittest module for Test Driven Development

2014-08-24 Thread Danny Yoo
>>> Is there a way that I can provide the file name command line parameters >>> to compare.py so that its get_args function can be tested? >> >> sys.argv is writeable, or better still, provide get_args() an optional >> argument to use instead of sys.argv.o > > > I don't understand what you mean by

Re: [Tutor] datetime substraction

2014-08-26 Thread Danny Yoo
> > I have written a script, however I'm not able to get the date substraction > math right, getting the following error > (Searched google and other resources too). > > Traceback (most recent call last): > File "./rsyslog_check.py", line 22, in > difft=cur_time-mt > TypeError: unsupported o

Re: [Tutor] Interacting with stderr

2014-08-27 Thread Danny Yoo
> Crude and incomplete and untested example: > > from subprocess import Popen, PIPE > > P = Popen("avconv ... lots of arguments...", shell=True, stderr=PIPE) > > for line in P.stderr: > ... examine the line from stderr ... > > # ok, we have read all of stderr now > xit = P.wait() >

Re: [Tutor] Interacting with stderr

2014-08-27 Thread Danny Yoo
>> Rather than construct the pipeline through the shell, do it through >> Python if you can. See: >> >> https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline > > But his use case is not using a shell pipeline, so irrelevant. It just makes > things more complex for him. Did I

Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Danny Yoo
On Thu, Aug 28, 2014 at 11:03 AM, leam hall wrote: > python 2.4.3 on Red Hat Linux. > > I'm starting a project and want to break the scripts into "input", > "output", and "ddl". I'd like to have a "lib" library directory for > local modules. The library directory would be at the same level as the

Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Danny Yoo
> > Fails on both Python 2.4 and 2.6 with either ".lib" or "..lib". > > ### code > #!/usr/bin/env python > > from ..lib import mymodule > > > In python/ddl, referencing ../lib/mymodule.py > > ./import_test.py > Traceback (most recent call last): > File "./import_test.py", line 3, in >

Re: [Tutor] Quick question for Tutor admin.

2014-08-28 Thread Danny Yoo
On Thu, Aug 28, 2014 at 3:25 PM, Crush wrote: > Am I allowed to attach screen shots to my emails? Hi Bo, If the informational content can be represented textually, then please try to avoid screenshots in favor of copy-and-paste. There are a few reasons for it. But one major reason why text is

Re: [Tutor] sorting distances for nearest neighbor

2014-08-29 Thread Danny Yoo
> How do you sort distances to prepare for nearest neighbor when the results > returned look like this from the below statements? It's unclear what you're asking. 1. Are you showing us the file content in the raw form: > Distance from 1 to > 16 is 43763.0757603 > 19 is 126516.988978 > 18 is 1

Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Danny Yoo
> now if i do this > > outfile = cStringIO.StringIO() > outfile.write(pyfromzip) > z=cPickle.load(outfile) Do you have to rewind the outfile so that the read is properly positioned? The following interaction: # >>> import StringIO >>> out = StringIO.StringIO() >>> ou

Re: [Tutor] Printing a list count - Help

2014-08-29 Thread Danny Yoo
> > The above code prints 8 lines, each being an entry for which item in > the list was either A or B. Again, I'm looking for the result to be > the number 8 itself - the total number of instances that A or B occurs > in the list. Hi Derek, Hint: the code currently prints a variable within the l

Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Danny Yoo
Hi Dillup, One other comment other than the zipfile stuff: you might want to consider something other than pickle format if you want interchangeability with other tools. JSON, for example, is pretty well-supported in the json library: https://docs.python.org/2/library/json.html and it has

Re: [Tutor] Interacting with stderr

2014-08-29 Thread Danny Yoo
On Fri, Aug 29, 2014 at 2:13 PM, Crush wrote: > I am now able to print stderr to the screen, however I still can not run > conditional statements against stderr. > > Please see the screenshots(SS) here... > > https://www.dropbox.com/sh/31wyjtvqymo94uk/AAAZaxwB27nw1nmz7tz69I5La?dl=0 Hi Bo, Cons

Re: [Tutor] Interacting with stderr

2014-08-29 Thread Danny Yoo
Hi Bo, One other thing: if you can avoid running commands as root, I'd strongly suggest doing so. Your second screenshot shows that you're running as root superuser, and the imaginary security demon that sits on my left shoulder is laughing uproariously as we speak. __

[Tutor] Fwd: Re: extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Danny Yoo
-- Forwarded message -- From: "diliup gabadamudalige" Date: Aug 29, 2014 8:34 PM Subject: Re: [Tutor] extracting a cPickle/pickle file from inside a zip file To: "Danny Yoo" Cc: Dear Danny, Thank for your invaluable advice which is much appreciated. My code f

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
> Now the problem is another one... And NOT related to PySide, it's pure > Python. The problem is in the 'get_date()' func > (http://pastebin.com/mPhJcXmF) - I get all the text from bankofcanada site > but when I reach 'line.strip()' I get an error, "'int' object has no > attribute 'strip'". You'v

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
> So the loop really should be: > > for line in fh.split("\n"): > ... Ah, apologies. Forgot that we're in Python 3 land. We have to be consistent with the types a lot more. This should be: for line in fh.split(b"\n"): ... Apologies. I should hav

Re: [Tutor] Interacting with stderr

2014-08-30 Thread Danny Yoo
>>> One other thing: if you can avoid running commands as root, I'd >>> strongly suggest doing so. Your second screenshot shows that you're >>> running as root superuser, and the imaginary security demon that sits >>> on my left shoulder is laughing uproariously as we speak. >> >> Haha Yes I am aw

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
Hi Juan, Take out your try/except block. It's "lying" in the sense that what's problematic isn't the failure to download. The exception handling is not doing well: it's hiding the true cause of the problem. After you take the exception handler out, try again. The error message should be a lot

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
Hi Juan, Wait, you are working with a CSV file, right? You should not be trying to parse this by hand if you can avoid it: there's a 'csv' parser library in the Standard Library. https://docs.python.org/3.1/library/csv.html So: import codecs import urll

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
As the error message suggests, the problem might be near line 40. Look at lines 40 and 41 in your program. print(rates[row[0]] + " / VALUE : " + str(value)) rates[row[0]] = value Look at it very carefully, and try to explain to yourself what those two lines mean.

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
On Sat, Aug 30, 2014 at 7:49 PM, Juan Christian wrote: > Let's see, the print is just "debug", it's not necessary in the program. > > 'row[0]' is the first element of the current row. Ex.: row = ['a', 'b', 'c', > 'd'] - row[0] would be 'a' > > 'rates' is a dictionary, 'rates[row[0]]' would update

Re: [Tutor] PySide 1.2.2 and Python 3 - "native Qt signal is not callable"

2014-08-30 Thread Danny Yoo
> > Everything seems to be working, but, when I try to really use the program > and convert something change the spinBox value I get: > > > ### > Traceback (most recent call last): > File "C:/.../currency.py", line 20, in update_ui > amount = (rates[from_] / rates[to]) * fromSpinBox.value() >

Re: [Tutor] calculate percents of items in a list

2014-08-31 Thread Danny Yoo
On Aug 31, 2014 11:34 AM, "LN A-go-go" wrote: > > > What would be a better way to calculate percentages of items in a list? > please > Without showing us your code, try to explain a few examples of the problem you're trying to solve, and show us expected answer. The problem of just showing co

Re: [Tutor] Good Text Editor/IDE for Python

2014-09-01 Thread Danny Yoo
On Sun, Aug 31, 2014 at 5:12 PM, Juan Christian wrote: > I've been using PyCharm to code in Python but it seems a bit "overpowered" > for this task, and there are some annoying bugs. I used Sublime Text 2 in > the past, but it seems to be dead now (last update was JUN/2013), so I don't > really kn

Re: [Tutor] How to count vehicle? I'm trying but my code don't increasing..

2014-09-02 Thread Danny Yoo
Hi Whees, You may not be asking your question on an appropriate forum. Python-tutor is meant for beginners to Python programming, not beginners to computer vision. That is, if you're doing a computer vision assignment, the expectation is that you should already know how to program Python at a ve

Re: [Tutor] How to count vehicle? I'm trying but my code don't increasing..

2014-09-02 Thread Danny Yoo
> > On Tue, Sep 2, 2014 at 7:01 AM, Whees Northbee wrote: >> If all of these confusing, I'll simplify the problem, I need to know if a >> point (x,y) exactly at a line where line is (ax1,ay) to (ax2,ay).. > > > Case in point: in the question above, you can't possibly be asking us > to help you wri

Re: [Tutor] New to Python..Need help

2014-09-04 Thread Danny Yoo
> I have a question regarding strings in python. I have a directory on my > MacBook Bro of about 13 files. I need to alter the file endings in that > directory. The files are on the order of > 'swp.113006004000_KLWX_0.0.5_PPI_v2','swp.113006004000_KLWX_0.0.5_PPI_v3'. I > need to remove the characte

Re: [Tutor] New to Python..Need help

2014-09-04 Thread Danny Yoo
On Thu, Sep 4, 2014 at 12:05 PM, taserian wrote: > Is there anything different between the filenames aside from that suffix > _vXX? If not, then you'll run into problems after the first filename is > changed; further attempts won't allow the change, since there's already a > file with that same na

Re: [Tutor] Tutor Digest, Vol 127, Issue 12

2014-09-04 Thread Danny Yoo
>> I downloaded notepad++. Can you please help me how to run python script in >> notepad++? > > > I only played with notepad++ briefly but I seem to recall it had a menu with > commands to 'make' and 'run' a file. You could configure the commands > associated with those menus in the settings somewh

[Tutor] How to detect colinearity?

2014-09-05 Thread Danny Yoo
> But if you're think I'm expert with python because I'm work with computer > vision > I'm not I'm newbie to both.. Ok. Since you've stated that you are a beginner, we now have to recalibrate how we're answering your questions. In that case, I would strongly suggest going through a basic progra

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Danny Yoo
>> @property >> def _avatar(self): >> return self._avatar Hi Joel, The above code looks strange to me. The method and the field name should not use the same name. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: ht

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Danny Yoo
@property def _avatar(self): return self._avatar >> >> Hi Joel, >> >> The above code looks strange to me. The method and the field name >> should not use the same name. > > ah! good catch Danny. I didn't write it, I was commenting on the OP code. > > But (and maybe this was discuss

<    14   15   16   17   18   19   20   21   22   >