Re: Python Scalability TCP Server + Background Game

2014-01-18 Thread Chris Angelico
On Sat, Jan 18, 2014 at 6:44 PM, wrote: >> Quick smoke test. How big are your requests/responses? You mention >> >> REST, which implies they're going to be based on HTTP. I would expect >> >> you would have some idea of the rough size. Multiply that by 50,000, >> >> and see whether your connectio

Re: How to write this as a list comprehension?

2014-01-18 Thread Peter Otten
Piet van Oostrum wrote: > Hi, > > I am looking for an elegant way to write the following code as a list > comprehension: > > labels = [] > for then, name in mylist: > _, mn, dy, _, _, _, wd, _, _ = localtime(then) > labels.append(somefunc(mn, day, wd, name)) > > So mylist is a list of t

Re: doctests compatibility for python 2 & python 3

2014-01-18 Thread Albert-Jan Roskam
On Fri, 1/17/14, Terry Reedy wrote: Subject: Re: doctests compatibility for python 2 & python 3 To: python-list@python.org Date: Friday, January 17, 2014, 10:10 PM On 1/17/2014 7:14 AM, Robin Becker wrote: > I tried this approach with a few m

Re: numpy.where() and multiple comparisons

2014-01-18 Thread Peter Otten
John Ladasky wrote: > On Friday, January 17, 2014 6:16:28 PM UTC-8, duncan smith wrote: > >> >>> a = np.arange(10) >> >>> c = np.where((2 < a) & (a < 7)) >> >>> c >> (array([3, 4, 5, 6]),) > > Nice! Thanks! > > Now, why does the multiple comparison fail, if you happen to know? 2 < a < 7 i

Re: Guessing the encoding from a BOM

2014-01-18 Thread Gregory Ewing
Chris Angelico wrote: On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence wrote: Every time I see it I picture Inspector Clouseau, "A BOM!!!" :) Special delivery, a berm! Were you expecting one? A berm? Is that anything like a shrubbery? -- Greg -- https://mail.python.org/mailman/listinfo/pyth

Re: How to write this as a list comprehension?

2014-01-18 Thread Piet van Oostrum
Rustom Mody writes: > On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote: [...] > >> Python misses a 'where' or 'let'-like construction as in Haskell. > > +1 > Yes Ive often been bitten by the lack of a 'comprehension-let' If it used only in a comprehension as in my exampl

Re: Guessing the encoding from a BOM

2014-01-18 Thread Chris Angelico
On Sat, Jan 18, 2014 at 8:41 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence >> wrote: >> >> Every time I see it I picture Inspector >>> >>> Clouseau, "A BOM!!!" :) >> >> >> Special delivery, a berm! Were you expecting one? > > > A berm? Is th

Re: How to write this as a list comprehension?

2014-01-18 Thread Matěj Cepl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 2014-01-17, 23:19 GMT, you wrote: > But defining the auxfunc takes away the elegance of a list > comprehension. Au contraire! Remember, that brevity is the sister of talent. I would definitively vote for labels = [make_label(then, name) f

Re: Python Scalability TCP Server + Background Game

2014-01-18 Thread phiwer
> (You're using Google Groups, which means your replies are > > double-spaced and your new text is extremely long lines. Please fix > > this, either by the fairly manual job of fixing every post you make, > > or the simple method of switching to a better client. Thanks.) > > > > My point was

python to enable javascript , tried selinium, ghost, pyQt4 already

2014-01-18 Thread Jaiprakash Singh
hi, can you please suggest me some method for study so that i can scrap a site having JavaScript behind it i have tried selenium, ghost, pyQt4, but it is slow and as a am working with thread it sinks my ram memory very fast. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to write this as a list comprehension?

2014-01-18 Thread Alain Ketterlin
Piet van Oostrum writes: [...] > I could define a auxiliary function like: > > def auxfunc(then, name): > _, mn, dy, _, _, _, wd, _, _ = localtime(then) > return somefunc(mn, day, wd, name) > > and then use > [auxfunc(then, name) for then, name in mylist] [...] > labels = [somefunc(mn,

Re: Python Scalability TCP Server + Background Game

2014-01-18 Thread Asaf Las
On Wednesday, January 15, 2014 8:37:25 PM UTC+2, phi...@gmail.com wrote: > My problem is as follows: > > 2) The network layer of the game server runs a separate process as well, > and my intention was to use gevent or tornado (http://nichol.as/asynchronous- >servers-in-python). > 3) The game

Re: Python Scalability TCP Server + Background Game

2014-01-18 Thread phiwer
Den lördagen den 18:e januari 2014 kl. 13:13:47 UTC+1 skrev Asaf Las: > On Wednesday, January 15, 2014 8:37:25 PM UTC+2, phi...@gmail.com wrote: > > > My problem is as follows: > > > > > > 2) The network layer of the game server runs a separate process as well, > > > and my intention was

Re: Python Scalability TCP Server + Background Game

2014-01-18 Thread Mark Lawrence
On 18/01/2014 12:40, phi...@gmail.com wrote: [snip the stuff I can't help with] Here's the link you need to sort the problem with double spacing from google groups https://wiki.python.org/moin/GoogleGroupsPython -- My fellow Pythonistas, ask not what our language can do for you, ask what you

Re: Python 3.x adoption

2014-01-18 Thread beliavsky
On Friday, January 17, 2014 6:03:45 PM UTC-5, Terry Reedy wrote: > On 1/17/2014 5:16 PM, beliav...@aol.com wrote: > > Python 2 and 3 are incompatible in ways that do not apply to Fortran > > > standards pre- and post- F77. > > > > As stated above, I disagree with respect to pre-F77 and F77

Re: [newbie] advice and comment wanted on first tkinter program

2014-01-18 Thread Jean Dupont
Op vrijdag 17 januari 2014 22:40:42 UTC+1 schreef Terry Reedy: > On 1/17/2014 8:20 AM, Jean Dupont wrote: > > > Dear all, > > > I made a simple gui with tkinter. I can imagine there are things which I > > > did which are "not optimal". So what I ask is to comment on my code > > > preferable wit

Re: [newbie] advice and comment wanted on first tkinter program

2014-01-18 Thread Oscar Benjamin
On 18 January 2014 14:52, Jean Dupont wrote: > > Thanks Peter and Terry Jan for the useful suggestions. One thing which I find > a bit weird: when asking for Python-help concerning raspberry pi code or > problems, a lot of people don't seem to be interested in helping out, that's > of course th

Re: How to write this as a list comprehension?

2014-01-18 Thread Rustom Mody
On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote: > Options I can think of: > You could do it in two steps... > time_name_pairs = ((localtime(then), name) for then, name in mylist) > labels = [somefunc(t.tm_mon, t.tm_mday, t.tm_wday, name) > for t, name in time_na

Re: How to write this as a list comprehension?

2014-01-18 Thread Jussi Piitulainen
Rustom Mody writes: > On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote: > > > What would a list-comp with `let` or `where` look like? Would it > > win the beauty contest against the loop? > > For me this is neat > > [somefunc(mn,day,wd,name) for (then, name) in mylist let >

Re: [newbie] advice and comment wanted on first tkinter program

2014-01-18 Thread Mark Lawrence
On 18/01/2014 15:12, Oscar Benjamin wrote: On 18 January 2014 14:52, Jean Dupont wrote: Thanks Peter and Terry Jan for the useful suggestions. One thing which I find a bit weird: when asking for Python-help concerning raspberry pi code or problems, a lot of people don't seem to be interested

Re: How to write this as a list comprehension?

2014-01-18 Thread Piet van Oostrum
Alain Ketterlin writes: > Piet van Oostrum writes: > [...] >> Python misses a 'where' or 'let'-like construction as in Haskell. > > "let x = v in e" really is (lambda x:e)(v) > You are right, but it is a lot less readable IMHO. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE

Python Simple program

2014-01-18 Thread indar kumar
Hello, I am a newbie. Can somebody help me write the code for following program? Write a program that takes student grades and prints out the GPA. The information is input, one student per line in the format:... The number of students is not known in advance. You should prompt the user for

Re: python to enable javascript , tried selinium, ghost, pyQt4 already

2014-01-18 Thread Denis McMahon
On Sat, 18 Jan 2014 03:54:17 -0800, Jaiprakash Singh wrote: > can you please suggest me some method for study so that i can > scrap a site having JavaScript behind it Please expand upon the requirement, are you trying to: a) replace server side javascript with server side python, or b) replace

Re: Python Simple program

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 5:00 AM, indar kumar wrote: > Hello, I am a newbie. Can somebody help me write the code for following > program? > > > Write a program that takes student grades and prints out the GPA. The > information is input, one student per line in the format: > ... > The number

Re: python to enable javascript , tried selinium, ghost, pyQt4 already

2014-01-18 Thread Chris Angelico
On Sat, Jan 18, 2014 at 10:54 PM, Jaiprakash Singh wrote: > hi, > > can you please suggest me some method for study so that i can scrap a > site having JavaScript behind it > > > i have tried selenium, ghost, pyQt4, but it is slow and as a am working > with thread it sinks my ram memory

Re: Python Simple program

2014-01-18 Thread Roy Smith
In article , indar kumar wrote: > Hello, I am a newbie. Can somebody help me write the code for following > program? > > > Write a program that takes student grades and prints out the GPA. The > information is input, one student per line in the format: > ... > The number of students is n

question about input() and/or raw_input()

2014-01-18 Thread Roy Smith
Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? -- https://mail.python.org/mailman/listinfo/python-list

Re: question about input() and/or raw_input()

2014-01-18 Thread Mark Lawrence
On 18/01/2014 18:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Not me personally. I guess raw_input must have been used somewhere at some time for something, o

Re: Python Simple program

2014-01-18 Thread indar kumar
On Saturday, January 18, 2014 11:00:47 AM UTC-7, indar kumar wrote: > Hello, I am a newbie. Can somebody help me write the code for following > program? > > > > > > Write a program that takes student grades and prints out the GPA. The > information is input, one student per line in the forma

Re: question about input() and/or raw_input()

2014-01-18 Thread Emile van Sebille
On 01/18/2014 10:30 AM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Yes - routinely. Emile -- https://mail.python.org/mailman/listinfo/python-list

Re: question about input() and/or raw_input()

2014-01-18 Thread Peter Otten
Roy Smith wrote: > Pardon me for being cynical, but in the entire history of the universe, > has anybody ever used input()/raw_input() for anything other than a > homework problem? I use it for pointless throwaway tools, sometimes via the cmd module, sometimes directly. I like that you can add

Re: Python Simple program

2014-01-18 Thread Roy Smith
In article <60955b74-7bc8-4c72-94e1-849015985...@googlegroups.com>, indar kumar wrote: > On Saturday, January 18, 2014 11:00:47 AM UTC-7, indar kumar wrote: > > Hello, I am a newbie. Can somebody help me write the code for following > > program? > > > > > > > > > > > > Write a program that

Re[2]: [newbie] advice and comment wanted on first tkinter program

2014-01-18 Thread Grawburg
The Raspberry Pi is exactly what got me started with Python. I'm at medium-sized science museum and used the Pi, Python, & tkinter to introduce kids to programming & Linux this past summer. Jean, feel free to contact me off-line for my experience with all three. Brian Grawburg Wilson, NC ---

Re: Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?

2014-01-18 Thread Mark Heieis
Stefan, Thank-you for the reply. I hadn't considered cpython, unfortunately the extension is too large a project to port at the moment. I ended up replacing the PyBuffer_New() segment with malloc() and passing back an object from PyByteArray_FromStringAndSize(). It seems to work. mrh. On 20

Need help vectorizing code

2014-01-18 Thread Kevin K
I have some code that I need help vectorizing. I want to convert the following to vector form, how can I? I want to get rid of the inner loop - apparently, it's possible to do so. X is an NxD matrix. y is a 1xD vector. def foo(X, y, mylambda, N, D, epsilon): ... for j in xrange(D):

Re: Need help vectorizing code

2014-01-18 Thread Joshua Landau
On 18 January 2014 20:51, Kevin K wrote: > def foo(X, y, mylambda, N, D, epsilon): > ... > for j in xrange(D): > aj = 0 > cj = 0 > for i in xrange(N): > aj += 2 * (X[i,j] ** 2) > cj += 2 * (X[i,j] * (y[i] - w.transpose()*X

Re: Need help vectorizing code

2014-01-18 Thread Kevin K
I didn't paste the whole function, note the ... before and after. I do use the values. I want to get rid of one of the loops so that the computation becomes O(D). Assume vectors a and c should get populated during the compute, each being 1xD. Thanks On Saturday, January 18, 2014 12:51:25 PM U

Re: Python declarative

2014-01-18 Thread Tim Roberts
serto...@gmail.com wrote: > >First, I don't like that all parenthesis, I like to differentiate >which type of delimiter is, this is not so bad if using spaces but >anyways it's a little more difficult. Second, In regard, to using >something like myWindow=Window rather than Window "myWindow", at

Re: numpy.where() and multiple comparisons

2014-01-18 Thread Tim Roberts
Peter Otten <__pete...@web.de> wrote: >John Ladasky wrote: > >> On Friday, January 17, 2014 6:16:28 PM UTC-8, duncan smith wrote: >> >>> >>> a = np.arange(10) >>> >>> c = np.where((2 < a) & (a < 7)) >>> >>> c >>> (array([3, 4, 5, 6]),) >> >> Nice! Thanks! >> >> Now, why does the multiple co

Re: question about input() and/or raw_input()

2014-01-18 Thread Terry Reedy
On 1/18/2014 1:30 PM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Homework problems (and 'toy' programs, such as hangman), whether in a programming class or elsewh

Re: python to enable javascript , tried selinium, ghost, pyQt4 already

2014-01-18 Thread Denis McMahon
On Sun, 19 Jan 2014 05:13:57 +1100, Chris Angelico wrote: > On Sat, Jan 18, 2014 at 10:54 PM, Jaiprakash Singh > wrote: >> hi, >> >> can you please suggest me some method for study so that i can >> scrap a site having JavaScript behind it >> >> >> i have tried selenium, ghost, pyQt4,

Re: Need help vectorizing code

2014-01-18 Thread Peter Otten
Kevin K wrote: > I have some code that I need help vectorizing. > I want to convert the following to vector form, how can I? I want to get > rid of the inner loop - apparently, it's possible to do so. X is an NxD > matrix. y is a 1xD vector. > > def foo(X, y, mylambda, N, D, epsilon): > ... >

Can post a code but afraid of plagiarism

2014-01-18 Thread indar kumar
Hi, I want to show a code for review but afraid of plagiarism issues. Kindly, suggest how can I post it for review here without masking it visible for public -- https://mail.python.org/mailman/listinfo/python-list

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Roy Smith
In article , indar kumar wrote: > Hi, > > I want to show a code for review but afraid of plagiarism issues. Kindly, > suggest how can I post it for review here without masking it visible for > public You can't. This is a public forum. One of the reasons people are willing to answer basic

Re: python to enable javascript , tried selinium, ghost, pyQt4 already

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 8:40 AM, Denis McMahon wrote: > On Sun, 19 Jan 2014 05:13:57 +1100, Chris Angelico wrote: > >> On Sat, Jan 18, 2014 at 10:54 PM, Jaiprakash Singh >> wrote: >>> hi, >>> >>> can you please suggest me some method for study so that i can >>> scrap a site having Java

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread indar kumar
@Roy Smith Can you help me privately because its an assignment and have to submit plagiarism free -- https://mail.python.org/mailman/listinfo/python-list

Reference counting and the use of PYTHONDUMPREFS

2014-01-18 Thread Anders Wegge Keller
During the final test of a bit of embedded python, I wanted to see if I had any hanging references. To my suprise, I ended up with a rather large amount, after running combinerefs.py. And even with the simplest[1] possible use of embedding, I end up with 13475 still-living references. If this i

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Roy Smith
In article , indar kumar wrote: > @Roy Smith > > Can you help me privately Sorry, no. -- https://mail.python.org/mailman/listinfo/python-list

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 9:32 AM, indar kumar wrote: > @Roy Smith > > Can you help me privately because its an assignment and have to submit > plagiarism free Are you sure the requirement precludes you posting your code? More likely, the rule is that you may not copy someone else's. When it's pos

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Ben Finney
indar kumar writes: > I want to show a code for review but afraid of plagiarism issues. Why? What solid basis do you have to fear someone plagiarising code that you want reviewed? There is already a vast amount of code licensed freely for anyone to use and derive from. What would make yours esp

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Ben Finney
indar kumar writes: > Can you help me privately because its an assignment and have to submit > plagiarism free Then the point of the assignment is defeated by seeking help here. Hopefully your instructors also read this forum and are now aware you are seeking to subvert the anti-plagiarism rule

'and' is not exactly an 'operator' (was Re: numpy.where() and multiple comparisons)

2014-01-18 Thread Terry Reedy
On 1/18/2014 3:50 AM, Peter Otten wrote: Unlike `&` `and` cannot be overridden (*), (*) I assume overriding would collide with short-cutting of boolean expressions. Yes. 'and' could be called a 'control-flow operator', but in Python it is not a functional operator. A functional binary op

Re: How to write this as a list comprehension?

2014-01-18 Thread John Allsup
Hi, I'd agree with the advice that it's not the best idea: readability sucks here, but consider the following: import time def somefunc(a,b,c,d): # dummy function return "{} - {} - {} : {}".format(a,b,c,d) l = [(time.time(),"name {}".format(n)) for n in range(100)] # dummy data # the li

Help with simple code that has database defined

2014-01-18 Thread indar kumar
I have to save students information in a database that is keeping continuously track of the information. Format is as follows: Information: Note: if this name already exists there in database, just update the information of that(name) e.g course,grade and date. Otherwise, add it. What I thi

Re: question about input() and/or raw_input()

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 8:33 AM, Terry Reedy wrote: > On 1/18/2014 1:30 PM, Roy Smith wrote: >> >> Pardon me for being cynical, but in the entire history of the universe, >> has anybody ever used input()/raw_input() for anything other than a >> homework problem? > > > Homework problems (and 'toy'

Re: question about input() and/or raw_input()

2014-01-18 Thread Rustom Mody
On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: > Pardon me for being cynical, but in the entire history of the universe, > has anybody ever used input()/raw_input() for anything other than a > homework problem? Similar 'cynicism' regarding print would be salutary for producin

Re: question about input() and/or raw_input()

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 3:15 PM, Rustom Mody wrote: > On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: >> Pardon me for being cynical, but in the entire history of the universe, >> has anybody ever used input()/raw_input() for anything other than a >> homework problem? > > Simila

Re: question about input() and/or raw_input()

2014-01-18 Thread Rustom Mody
On Sunday, January 19, 2014 9:51:36 AM UTC+5:30, Chris Angelico wrote: > On Sun, Jan 19, 2014 at 3:15 PM, Rustom Mody wrote: > > On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: > >> Pardon me for being cynical, but in the entire history of the universe, > >> has anybody ever use

Re: question about input() and/or raw_input()

2014-01-18 Thread Chris Angelico
On Sun, Jan 19, 2014 at 3:43 PM, Rustom Mody wrote: > Because these two pieces of code > def foo(x): print x+1 > def bar(x): return x+1 > > look identical (to a beginner at least) > foo(3) > 4 bar(3) > 4 As do these pieces of code: >>> def quux(x): return str(x+1) >>> de

graphical python

2014-01-18 Thread buck
I'm trying to work through Skienna's algorithms handbook, and note that the author often uses graphical representations of the diagrams to help understand (and even debug) the algorithms. I'd like to reproduce this in python. How would you go about this? pyQt, pygame and pyglet immediately come

Re: question about input() and/or raw_input()

2014-01-18 Thread Steven D'Aprano
On Sat, 18 Jan 2014 13:30:20 -0500, Roy Smith wrote: > Pardon me for being cynical, but in the entire history of the universe, > has anybody ever used input()/raw_input() for anything other than a > homework problem? Yes. They are excellent for interactive command line tools. -- Steven -- htt

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Steven D'Aprano
On Sat, 18 Jan 2014 14:32:21 -0800, indar kumar wrote: > @Roy Smith > > Can you help me privately because its an assignment and have to submit > plagiarism free Then don't plagiarise. Plagiarism means YOU copy other people. You shouldn't get in trouble because other people copy you. Talk to

Re: Can post a code but afraid of plagiarism

2014-01-18 Thread Devin Jeanpierre
On Sat, Jan 18, 2014 at 10:31 PM, Steven D'Aprano wrote: > Plagiarism means YOU copy other people. You shouldn't get in trouble > because other people copy you. Normally, both the person copying and the person who gave away their work to be copied are punished. It simplifies figuring out who to p

Re: Beginner Tutorials

2014-01-18 Thread simsonsjanis
On Friday, 18 January 2013 16:47:52 UTC+2, Rik wrote: > Hi, I've developed a website for beginners to Python. I'd appreciate any > comments or criticism. It's still under development, and should be finished > in the next few months. Oh, and it's free to use. > > > > www.usingpython.com code