Re: Please critique my script

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 4:03 AM, Ellerbee, Edward wrote: > for makenewlist in range(0,count): >     sortlist.append(npalist.pop(0) + nxxlist.pop(0)) This can alternatively be done with map(): sortlist = map(lambda x,y: x+y, npalist, nxxlist) However, I'm not sure what your code is meant to do i

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 11:32 AM, Steven D'Aprano wrote: > Inside wrote: > >> As telling in the subject,because "list" and "tuple" aren't functions,they >> are types.Is that right? > > Yes they are types. But they can still be used as functions. Does it matter? Python is duck-typed, even in its d

Re: Multiplicity and Asininity in Tkinter Event API

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 8:34 AM, rantingrick wrote: > >   >   >   >   >   > > That's it. Go ahead, try to prove me wrong! > Does MouseClick mean Mouse Button Down, or does it mean Mouse Button Pressed Then Released Within A Short Time Without The Mouse Moving In Between? Both events are needed.

Re: None versus MISSING sentinel -- request for design feedback

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 3:28 PM, Steven D'Aprano wrote: > My question is, should I accept None as the missing value, or a dedicated > singleton? > > In favour of None: it's already there, no extra code required. People may > expect it to work. > > Against None: it's too easy to mistakenly add None

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-14 Thread Michael Hrivnak
Was tried at least once before: http://www.python.org/dev/peps/pep-0287/ Check in here with your ideas: http://www.python.org/community/sigs/current/doc-sig/ Have any other languages mandated the use of a specific documentation markup? Michael On Thu, Jul 14, 2011 at 7:02 PM, rantingrick wrote

None versus MISSING sentinel -- request for design feedback

2011-07-14 Thread Steven D'Aprano
Hello folks, I'm designing an API for some lightweight calculator-like statistics functions, such as mean, standard deviation, etc., and I want to support missing values. Missing values should be just ignored. E.g.: mean([1, 2, MISSING, 3]) => 6/3 = 2 rather than 6/4 or raising an error. My ques

Re: json decode issue

2011-07-14 Thread Nobody
On Thu, 14 Jul 2011 10:22:44 -0700, Miki Tebeka wrote: > I'm trying to decode JSON output of a Java program (jackson) and having > some issues. The cause of the problem is the following snippet: > { > "description": "... lives\uMOVE™ OFFERS ", > } > Which causes ValueError: Invalid

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Ben Finney
Inside writes: > But I can't follow your opinion.Why?because of the list & tuple are > placed at built-in function,so before I type 'list' unintentionally on > the pyshell and it show me "", I never know that the name > 'list' is a type,I used to consider it's a function to produce 'list' > type.

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Terry Reedy
On 7/14/2011 9:51 PM, Ben Finney wrote: Steven D'Aprano writes: Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? At one time (before 2.2), they were functions and not classes. Yes they are types. But they can still be used

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Inside
Hey guy,thx for you feedback first. But I can't follow your opinion.Why?because of the list & tuple are placed at built-in function,so before I type 'list' unintentionally on the pyshell and it show me "", I never know that the name 'list' is a type,I used to consider it's a function to produce

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Corey Richardson
Excerpts from rantingrick's message of Thu Jul 14 21:36:15 -0400 2011: > On Jul 14, 8:21pm, Inside wrote: > > As telling in the subject,because "list" and "tuple" aren't functions,they > > are types.Is that right? > > You wanna see some warts in the docs. Okay, try to use the search box > to fin

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Ben Finney
Steven D'Aprano writes: > Inside wrote: > > > As telling in the subject,because "list" and "tuple" aren't functions,they > > are types.Is that right? > > Yes they are types. But they can still be used as functions. Does it matter? As a newcomer to the documentation I looked fruitlessly in the ta

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread rantingrick
On Jul 14, 8:21 pm, Inside wrote: > As telling in the subject,because "list" and "tuple" aren't functions,they > are types.Is that right? You wanna see some warts in the docs. Okay, try to use the search box to find list, dict, or tuple and see what happens... http://docs.python.org/ Search: [

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Steven D'Aprano
Inside wrote: > As telling in the subject,because "list" and "tuple" aren't functions,they > are types.Is that right? Yes they are types. But they can still be used as functions. Does it matter? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Inside
As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-14 Thread Ben Finney
rantingrick writes: > --- > New Syntax Specification For Documentation Strings > --- > > """ {DOC TAG HERE}: {MODULE_NAME|SHORT_SUMMARY_HERE}. > {NEWLINE} > {LONG_DESCRIPTION_HERE} > {NEWLINE} > Arguments: (if applicable) >

Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-14 Thread rantingrick
Hello Folks, Lately i have been musing over the ideas of method tagging. Specifically i am referring to method identifiers. As most of you know i had proposed to add "syntactical markers" to the language to deal with the ambiguities that arise whist eyeball parsing sub classed methods that clobbe

Re: Please critique my script

2011-07-14 Thread MRAB
On 14/07/2011 21:53, Peter Otten wrote: MRAB wrote: for line2 in nxxReg.findall(soup): nxxlist.insert(count2, line2) count2 = count2 + 1 enumerate will help you here: for count2, line2 in enumerate(nxxReg.findall(soup)): nxxlist.insert(count2, line2) An insert() at the end

Multiplicity and Asininity in Tkinter Event API

2011-07-14 Thread rantingrick
# Multiplicity and Asininity in Tkinter Event API! # The problems with Tkinter events are two fold: Probl

Python threading/multiprocessing issue.

2011-07-14 Thread Brandon Harris
I'm working on a tool that runs a number of process is separate thread. I've, up to this point, been using threading.Thread, but from what I read multiprocess will allow multiple processors to be used From the python docs on multiprocessing. I have run into an issue when modifying the thread obj

Re: PyCon Australia 2011: Schedule Announced

2011-07-14 Thread Laura Creighton
Hi Ryan. Best of luck with the conference. >Thanks also to Linux Australia, who provide the overarching legal and >organisational structure for PyCon Australia. I want to talk to somebody from Linux Australia about this overarching legal and organisational structure. Do you have an email addre

Re: Please critique my script

2011-07-14 Thread Peter Otten
MRAB wrote: >> for line2 in nxxReg.findall(soup): >> nxxlist.insert(count2, line2) >> count2 = count2 + 1 >> > enumerate will help you here: > for count2, line2 in enumerate(nxxReg.findall(soup)): > nxxlist.insert(count2, line2) An insert() at the end of a list is usually spelt appe

Re: Possible File iteration bug

2011-07-14 Thread Hrvoje Niksic
Billy Mays writes: > Is there any way to just create a new generator that clears its > closed` status? You can define getLines in terms of the readline file method, which does return new data when it is available. def getLines(f): lines = [] while True: line = f.readline()

Re: Possible File iteration bug

2011-07-14 Thread Terry Reedy
On 7/14/2011 3:46 PM, Billy Mays wrote: I noticed that if a file is being continuously written to, the file generator does not notice it: Because it does not look, as Ian explained. def getLines(f): lines = [] for line in f: lines.append(line) return lines This nearly duplicates .readlines,

Re: Possible File iteration bug

2011-07-14 Thread Billy Mays
On 07/14/2011 04:00 PM, Ian Kelly wrote: On Thu, Jul 14, 2011 at 1:46 PM, Billy Mays wrote: def getLines(f): lines = [] for line in f: lines.append(line) return lines with open('/var/log/syslog', 'rb') as f: lines = getLines(f) # do some processing with lines #

Re: json decode issue

2011-07-14 Thread Terry Reedy
On 7/14/2011 3:20 PM, MRAB wrote: On 14/07/2011 18:22, Miki Tebeka wrote: Greetings, I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { "description": "... lives\uMOVE™ OFFERS ", } Which causes ValueError: In

Re: Possible File iteration bug

2011-07-14 Thread Ian Kelly
On Thu, Jul 14, 2011 at 1:46 PM, Billy Mays wrote: > def getLines(f): >    lines = [] >    for line in f: >        lines.append(line) >    return lines > > with open('/var/log/syslog', 'rb') as f: >    lines = getLines(f) >    # do some processing with lines >    # /var/log/syslog gets updated in

Possible File iteration bug

2011-07-14 Thread Billy Mays
I noticed that if a file is being continuously written to, the file generator does not notice it: def getLines(f): lines = [] for line in f: lines.append(line) return lines with open('/var/log/syslog', 'rb') as f: lines = getLines(f) # do some processing with lines

Re: json decode issue

2011-07-14 Thread MRAB
On 14/07/2011 18:22, Miki Tebeka wrote: Greetings, I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { "description": "... lives\uMOVE™ OFFERS ", } Which causes ValueError: Invalid \u es

Re: Please critique my script

2011-07-14 Thread MRAB
[snip] raw_input() returns a string, so there's no need for these 3 lines: > y = str(y) > z = str(z) > p = str(p) > pagedef = ("http://www.localcallingguide.com/xmllocalprefix.php?npa="; + y + "&nxx=" + z) > print "Querying", pagedef > > #--Get info from NANPA.com -- > urllib2.inst

RE: Please critique my script

2011-07-14 Thread Gerald Britton
For me, there are some things I don't like much. One-character variable names stand out (tend to make the code hard to read). Violation of PEP 8 guidelines, especially wrt spacing. e.g. result.append("%s[%s]%s" % (lastprefix, tails, lastsuffix)) not result.append("%s[%s]%s"%(lastprefix,tails,l

Re: String formatting - mysql insert

2011-07-14 Thread Christian
On 14 Jul., 17:31, Billy Mays wrote: > On 07/14/2011 11:00 AM, Christian wrote: > > > > > > > > > > > Hi, > > > I get some problem  when i like to set the table name dynamic. > > I'm appreciate for any help. > > > Christian > > > ### works > > newcur.execute (  """ INSERT INTO events (id1,id2

Please critique my script

2011-07-14 Thread Ellerbee, Edward
I've been working on this for 3 weeks as a project while I'm learning python. It's ugly, only function in there is from a fellow lister, but it works perfectly and does what it is intended to do. I'd love to hear comments on how I could improve this code, what would be good to turn into a function

json decode issue

2011-07-14 Thread Miki Tebeka
Greetings, I'm trying to decode JSON output of a Java program (jackson) and having some issues. The cause of the problem is the following snippet: { "description": "... lives\uMOVE™ OFFERS ", } Which causes ValueError: Invalid \u escape. Any ideas on how to fix this? Thanks,

Re: How can I make a program automatically run once per day?

2011-07-14 Thread Ian Kelly
On Thu, Jul 14, 2011 at 11:00 AM, monkeys paw wrote: > You could use the below code. time.sleep(# seconds in a day) > where i == 30 would run once a day for a month > > import time > i=0 > while (1): >        print 'hello' >        time.sleep(2)   # Change this to number of seconds in a day >    

Re: How can I make a program automatically run once per day?

2011-07-14 Thread monkeys paw
On 7/9/2011 10:01 PM, John Salerno wrote: Thanks everyone! I probably should have said something like "Python, if possible and efficient, otherwise any other method" ! :) I'll look into the Task Scheduler. Thanks again! You could use the below code. time.sleep(# seconds in a day) where i == 30

Re: String formatting - mysql insert

2011-07-14 Thread Billy Mays
On 07/14/2011 11:00 AM, Christian wrote: Hi, I get some problem when i like to set the table name dynamic. I'm appreciate for any help. Christian ### works newcur.execute ( """ INSERT INTO events (id1,id2) VALUES (%s,%s); """ , (rs[1],rs[2])) ### works not newcur.execute ( """ INSE

Re: String formatting - mysql insert

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 1:00 AM, Christian wrote: > Hi, > > I get some problem  when i like to set the table name dynamic. > I'm appreciate for any help. > > ### works but is not really perfect: None from rs list result in > "None" instead of NULL. > newcur.execute (  """ INSERT INTO %s_events (id

Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-14 Thread Wanderer
On Jul 14, 10:34 am, Grant Edwards wrote: > On 2011-07-13, Thorsten Kampe wrote: > > > * Grant Edwards (Wed, 13 Jul 2011 13:03:22 + (UTC)) > >> On 2011-07-13, Thorsten Kampe wrote: > > >> >> and that that block is to be considered in relation to what was just > >> >> said, before the colon.

String formatting - mysql insert

2011-07-14 Thread Christian
Hi, I get some problem when i like to set the table name dynamic. I'm appreciate for any help. Christian ### works newcur.execute ( """ INSERT INTO events (id1,id2) VALUES (%s,%s); """ , (rs[1],rs[2])) ### works not newcur.execute ( """ INSERT INTO %s_events (id1,id2) VALUES (%s,

Re: Suppressing newline writing to file after variable

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 12:53 AM, Ellerbee, Edward wrote: > Holy cow, that's perfect! > > Thanks so much :) > > Would it be alright if I post my code on the list for critiquing? I'm > learning python to supplement my voice engineering position - time > consuming tasks that can be automated will ta

RE: Suppressing newline writing to file after variable

2011-07-14 Thread Ellerbee, Edward
Holy cow, that's perfect! Thanks so much :) Would it be alright if I post my code on the list for critiquing? I'm learning python to supplement my voice engineering position - time consuming tasks that can be automated will take less time. Edward Ellerbee -Original Message- From: pyt

Re: Suppressing newline writing to file after variable

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 12:04 AM, Ellerbee, Edward wrote: > Hey Chris, > > I was reading over this again, trying to understand the logic (I'm a > n00b) > > Could you explain this a bit? I'd like to build this emit function, but > I still don't have a firm grasp on functions. All of my code is line

Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-14 Thread Grant Edwards
On 2011-07-13, Thorsten Kampe wrote: > * Grant Edwards (Wed, 13 Jul 2011 13:03:22 + (UTC)) >> On 2011-07-13, Thorsten Kampe wrote: >> >> >> and that that block is to be considered in relation to what was just >> >> said, before the colon. >> > >> > The indentation makes it abundantly clear t

PyDev 2.2.1 Released

2011-07-14 Thread Fabio Zadrozny
Hi All, PyDev 2.2.1 has been released Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- Quick-outline * Parent methods may be shown with a 2nd Ctrl+O. * The initial node is selected with the current lo

RE: I don't know list, I not good at list.

2011-07-14 Thread Ellerbee, Edward
Thank you all for the advice, let me spin this in a different way. I've built a program that goes to the NANPA website, scrapes area code/exchange (npa/nxx) digits for a specified area - be it carolina, alabama, texas, etc - drops it into a file, then massages the data and prints out the correct f

Re: Howto Deferred

2011-07-14 Thread Jean-Paul Calderone
On Jul 14, 3:07 am, marco wrote: > Hello gals and guys, > > I'm an experienced Python user and I'd like to begin playing with > Twisted. > I started RTFM the tutorial advised on the official site and I found it > really useful and well done. > > Now I'd like to practice a bit by coding a little pr

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-14 Thread Carl Banks
On Wednesday, July 13, 2011 5:39:16 AM UTC-7, Anthony Kong wrote: [snip] > I think I will go through the following items: > > itertools module > functools module > concept of currying ('partial') > > > I would therefore want to ask your input e.g. > > Is there any good example to illustrate the

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-14 Thread Jonathan Hartley
On Jul 14, 4:32 am, Gregory Ewing wrote: > Anthony Kong wrote: > > So I have picked this topic for one of my presentation. It is because > > functional programming technique is one of my favorite in my bag  of python > > trick. > > I'm not sure it's a good idea to emphasise functional > programmi

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-14 Thread Jonathan Hartley
On Jul 13, 1:39 pm, Anthony Kong wrote: > (My post did not appear in the mailing list, so this is my second try. > Apology if it ends up posted twice) > > Hi, all, > > If you have read my previous posts to the group, you probably have some idea > why I asked this question. > > I am giving a few

Re: [TWISTED] Howto Deferred

2011-07-14 Thread Chris Angelico
On Thu, Jul 14, 2011 at 5:07 PM, marco wrote: > Now I'd like to practice a bit by coding a little program that reads > strings from a serial device and redirects them remotely via TCP. For > that sake I'm trying to use deferred. The obvious solution (to my mind) is two threads, one for each direc

[TWISTED] Howto Deferred

2011-07-14 Thread marco
Hello gals and guys, I'm an experienced Python user and I'd like to begin playing with Twisted. I started RTFM the tutorial advised on the official site and I found it really useful and well done. Now I'd like to practice a bit by coding a little program that reads strings from a serial device an