Re: Experiences/guidance on teaching Python as a first programming language

2013-12-12 Thread Rhodri James
On Wed, 11 Dec 2013 16:18:08 -, Mark Lawrence wrote: On 11/12/2013 16:04, Chris Angelico wrote: I strongly believe that a career programmer should learn as many languages and styles as possible, but most of them can wait. I chuckle every time I read this one. Five years per language,

Re: Optimizing list processing

2013-12-12 Thread Steven D'Aprano
On Thu, 12 Dec 2013 13:40:36 -0500, Terry Reedy wrote: > On 12/12/2013 7:08 AM, Steven D'Aprano wrote: > >> Please don't focus on the algorithm I gave. Focus on the fact that I >> could write it like this: >> >> if some condition to do with the computer's available memory: >> make modificat

Re: [newbie] trying socket as a replacement for nc

2013-12-12 Thread Dave Angel
On Thu, 12 Dec 2013 13:27:16 -0800, Dan Stromberg wrote: On Thu, Dec 12, 2013 at 6:16 AM, Grant Edwards wrote: I haven't done a lot of UDP, but are you pretty sure UDP can't at least fragment large packets? What's a router or switch to do if the Path MTU isn't large enough for an original

Re: Optimizing list processing

2013-12-12 Thread Chris Angelico
On Fri, Dec 13, 2013 at 11:14 AM, Steven D'Aprano wrote: > Back in the 1980s, when I was a Mac user and occasional programmer, there > were memory manager routines which (if I recall correctly) would tell you > whether or not an allocation would succeed or not. Macs of that vintage > didn't have v

Re: min max from tuples in list

2013-12-12 Thread Denis McMahon
On Wed, 11 Dec 2013 23:25:53 -0800, Robert Voigtländer wrote: > I have a list like this: > > a = [(52, 193), .. (36, 133)] # iterate over the list of tuples # creates a dictionary n0:[n1a, n1b, n1c ... ] # from tuples (n0,n1a), (n0,n1b), (n0,n1c) ... b = {} for x in a: if x[0] in b:

Knapsack Problem Without Value

2013-12-12 Thread geezle86
Hi, I wanna ask about Knapsack. I do understand what Knapsack is about. But this one i faced is a different problem. There is no value. I mean, it's like this, for example. I have 4 beams [X0, X1, X2, X3]. Each 1, 2, 2, 3 cm long. I want to make a new 6 cm long connected-beam from these 4 beam

Re: min max from tuples in list

2013-12-12 Thread Steven D'Aprano
On Thu, 12 Dec 2013 13:54:10 +0100, Peter Otten wrote: > Steven D'Aprano wrote: > >> In any case, sorting in Python is amazingly fast. You may be pleasantly >> surprised that a version that sorts your data, while nominally O(N log >> N), may be much faster than an O(N) solution that doesn't requi

Re: Knapsack Problem Without Value

2013-12-12 Thread Gary Herron
On 12/12/2013 06:08 PM, [email protected] wrote: Hi, I wanna ask about Knapsack. I do understand what Knapsack is about. But this one i faced is a different problem. There is no value. I mean, it's like this, for example. I have 4 beams [X0, X1, X2, X3]. Each 1, 2, 2, 3 cm long. I want to ma

Re: Optimizing list processing

2013-12-12 Thread Steven D'Aprano
On Thu, 12 Dec 2013 16:08:33 +0100, Peter Otten wrote: > Steven D'Aprano wrote: [...] >> So, ideally I'd like to write my code like this: >> >> >> table = [(x, i) for i,x in enumerate(iterable)] table.sort() >> if len(table) < ?: >> table = [i for x,i in table] >> else: >> for x, i i

Re: [newbie] trying socket as a replacement for nc

2013-12-12 Thread Jean Dubois
Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg: > On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois wrote: > > > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: > > >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois wrote: > > >> > > >> I have an ethernet-r

Re: [newbie] trying socket as a replacement for nc

2013-12-12 Thread Dan Stromberg
On Thu, Dec 12, 2013 at 7:23 PM, Jean Dubois wrote: > Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg: >> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois >> wrote: >> >> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: >> >> >> On Wed, Dec 11, 2013 at 3:0

Using pythons smtp server

2013-12-12 Thread Vincent Davis
I have an app that generates a file one a day and would like to email it using pythons SMTP server. http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer The documentation is kinda sparse and I cant seem to find any good examples. Basically what I want to do; when my app runs it would initi

Need help with file object

2013-12-12 Thread Unix SA
Hello, I am facing some issue when copying or moving file f=open('/tmp/file1') s=open('/tmp/file2') for line in f: if 'match' not in line: s.write(line) import shutil shutil.move(s, f) With above prog I am getting error TypeError: coercing to Unicode: need sting or buffer, file found W

Re: Need help with file object

2013-12-12 Thread Christopher Welborn
On 12/12/2013 10:29 PM, Unix SA wrote: Hello, I am facing some issue when copying or moving file f=open('/tmp/file1') s=open('/tmp/file2') for line in f: if 'match' not in line: s.write(line) import shutil shutil.move(s, f) With above prog I am getting error TypeError: coercing to U

Re: Need help with file object

2013-12-12 Thread rusi
On Friday, December 13, 2013 9:59:25 AM UTC+5:30, Unix SA wrote: > s=open('/tmp/file2') >s.write(line) Among other things you are missing a write mode (2nd optional argument to open) http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files -- https://mail.python.org/

Re: Optimizing list processing

2013-12-12 Thread rusi
On Friday, December 13, 2013 8:31:37 AM UTC+5:30, Steven D'Aprano wrote: > I don't know of any reasonable way to tell at runtime which of the two > algorithms I ought to take. Hard-coding an arbitrary value > ("if len(table) > 500") is not the worst idea I've ever had, but I'm > hoping for

Re: Need help with file object

2013-12-12 Thread John Gordon
In Unix SA writes: > f=open('/tmp/file1') > s=open('/tmp/file2') > for line in f: > if 'match' not in line: > s.write(line) > import shutil > shutil.move(s, f) > With above prog I am getting error > TypeError: coercing to Unicode: need sting or buffer, file found > What that means an

Re: Python Script

2013-12-12 Thread Amimo Benja
On Thursday, December 12, 2013 9:35:23 PM UTC+3, Gary Herron wrote: > On 12/12/2013 10:05 AM, Amimo Benja wrote: > > > I have an issue with a Python script that I will show as follows: > > > http://codepad.org/G8Z2ConI > > > > > > Assume that you have three (well defined) classes: AirBase and V

Re: Python Script

2013-12-12 Thread Amimo Benja
On Thursday, December 12, 2013 9:55:29 PM UTC+3, Terry Reedy wrote: > On 12/12/2013 1:35 PM, Gary Herron wrote: > > > On 12/12/2013 10:05 AM, Amimo Benja wrote: > > >> I have an issue with a Python script that I will show as follows: > > >> http://codepad.org/G8Z2ConI > > >> > > >> Assume that

Re: Python Script

2013-12-12 Thread Amimo Benja
On Thursday, December 12, 2013 9:59:26 PM UTC+3, MRAB wrote: > On 12/12/2013 18:05, Amimo Benja wrote: > > > I have an issue with a Python script that I will show as follows: > > > http://codepad.org/G8Z2ConI > > > > > > Assume that you have three (well defined) classes: AirBase and VmNet, > >

Re: min max from tuples in list

2013-12-12 Thread Robert Voigtländer
>I've heard the term used often. It means something like, "performs >well" or "runs fast". It may or may not be an English word, but that >doesn't stop people from using it :-) > If "google" can be used to mean "make huge amouts of money with a > product that is inherently flawed" then I'll

request for guidance

2013-12-12 Thread jennifer stone
greetings I am a novice who is really interested in contributing to Python projects. How and where do I begin? thanking you in anticipation -- https://mail.python.org/mailman/listinfo/python-list

Re: load_module for import entire package

2013-12-12 Thread Sergey
> This should work: > def get_obj(): > tmp = load_package_strict("tmp", basedir) > return tmp.main.TTT() Thank you:) I can only mention that it is working only if __init__.py of pkg contains line: import main To avoid modules caching I copy package to the new folder with anot

<    1   2