Re: variable vs. object

2015-11-30 Thread Nagy László Zsolt
> a=10 > > 'a' is an integer. Is it an object too? In Python, objects have an identity. When you do "a=10" then you *bind* the object to the name *a*. By "variable", the documentation refers to a name that was bound to an object. This is different from many other low level languages. For example:

Re: variable vs. object

2015-11-30 Thread Chris Angelico
On Mon, Nov 30, 2015 at 1:06 PM, fl wrote: > For example, > > a=10 > > 'a' is an integer. Is it an object too? Other people have explained the difference between the name "a" and the object it's bound to... but to the extent that "a" is an integer, yes it most definitely is an object. To be speci

Re: An Educational Software Platform written in Python

2015-11-30 Thread Andrew Farrell
I would look first at the open source software released by EdX: https://open.edx.org/ On Sat, Nov 28, 2015 at 10:39 AM, Marko Rauhamaa wrote: > Cai Gengyang : > > > Can I create something like this entirely in Python, > > Absolutely. It will only take ten to one hundred years for one person to >

it's posible? raw audio encoder to vorbis

2015-11-30 Thread Heber Futuri
Receipt from websocket server audio raw and I want to encode ogg help! :( from websocket_server import WebsocketServer # Called when a client sends a messagedef data_received(client, server, datos): #HERE encoder "datos" to ogg and save data PORT=9001 server = WebsocketServer(PORT) server.s

Caret key quits idle on pt keyboard

2015-11-30 Thread Osvaldo Dias dos Santos via Python-list
Hi, I can’t enter a caret in regex on a Portuguese keyboard because by pressing it, IDLE quits. Any help ? Thanks. Kind regards, Osvaldo -- https://mail.python.org/mailman/listinfo/python-list

Fwd: convert php in to python

2015-11-30 Thread RENISH RUDANI
Hi, Please help me to convert this code in python. *Thanks & Regards,* *Renish Rudani* *Action Speaks Louder than Words* -- https://mail.python.org/mailman/listinfo/python-list

Re: I can't understand re.sub

2015-11-30 Thread Erik
On 29/11/15 21:36, Mr Zaug wrote: I need to use re.sub to replace strings in a text file. Do you? Is there any other way? result = re.sub(pattern, repl, string, count=0, flags=0); I think I understand that pattern is the regex I'm searching for and repl is the thing I want to substitute for

Re: Caret key quits idle on pt keyboard

2015-11-30 Thread Chris Angelico
On Mon, Nov 30, 2015 at 12:30 AM, Osvaldo Dias dos Santos via Python-list wrote: > I can’t enter a caret in regex on a Portuguese keyboard because by pressing > it, IDLE quits. > Any help ? Hmm. This could be part of the known issues with Tk (on which Idle depends) and non-BMP characters, but a

Re: I can't understand re.sub

2015-11-30 Thread Jussi Piitulainen
Erik writes: > On 29/11/15 21:36, Mr Zaug wrote: >> This should be simple, right? > > It is. And it could be even simpler if you don't bother with regexes > at all (if your input is as fixed as you say it is): > > >>> foo = "foo bar baz spam CONTENT_PATH bar spam" > >>> ' Substitute '.join(foo.spl

Re: New JSON encoding method proposal for custom objects

2015-11-30 Thread Marco Kaulea
Hi, I think his goal is not to load the data back into python, but to use it to provide some kind of REST-Style interface. An example would be, if you have a class instance of a record of a movie, that it could be simply encoded and send over the wire to display. Without necessarily recreating the

Re: convert php in to python

2015-11-30 Thread Chris Angelico
On Fri, Nov 27, 2015 at 11:52 PM, RENISH RUDANI wrote: > Please help me to convert this code in python. > > > *Thanks & Regards,* > > *Renish Rudani* > > *Action Speaks Louder than Words* Sure. #!/usr/bin/python3 """Emit no output""" You didn't provide any PHP code, so the equivalent Python cod

Re: Generate config file from template using Python search and replace.

2015-11-30 Thread Peter Otten
Mr Zaug wrote: > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: >> Mr Zaug wrote: >> >> > When I run this script on OS X El Capitan, I see, >> > >> > # permission sensitive cache >> > $include "_dispatcher_shared_auth-checker: >> > >> > Was I supposed to incorporate

Re: New JSON encoding method proposal for custom objects

2015-11-30 Thread cescus92
Hello everyone and thank you for your interest! The Peter's code is very similar to what I think the default JSON encoder should be. The advantage of the method that I propose is that you should not care anymore about which encoder you're going to use even in case of different class instance

Re: How can I count word frequency in a web site?

2015-11-30 Thread ryguy7272
On Sunday, November 29, 2015 at 7:49:40 PM UTC-5, ryguy7272 wrote: > I'm trying to figure out how to count words in a web site. Here is a sample > of the link I want to scrape data from and count specific words. > http://finance.yahoo.com/q/h?s=STRP+Headlines > > I only want to count certain wor

Re: How can I count word frequency in a web site?

2015-11-30 Thread ryguy7272
On Sunday, November 29, 2015 at 9:51:46 PM UTC-5, Laura Creighton wrote: > In a message of Sun, 29 Nov 2015 21:31:49 -0500, Cem Karan writes: > >You might want to look into Beautiful Soup > >(https://pypi.python.org/pypi/beautifulsoup4), which is an HTML > >screen-scraping tool. I've never used

Re: Caret key quits idle on pt keyboard

2015-11-30 Thread Random832
On 2015-11-30, Chris Angelico wrote: > Hmm. This could be part of the known issues with Tk (on which Idle > depends) and non-BMP characters, but a caret should be safe. Is there a known issue with dead keys? From what I can find the Portuguese keyboard doesn't have a "proper" caret, it has a circ

Re: Caret key quits idle on pt keyboard

2015-11-30 Thread Chris Angelico
On Tue, Dec 1, 2015 at 2:10 AM, Random832 wrote: > On 2015-11-30, Chris Angelico wrote: >> Hmm. This could be part of the known issues with Tk (on which Idle >> depends) and non-BMP characters, but a caret should be safe. > > Is there a known issue with dead keys? From what I can find the > Portu

Re: Caret key quits idle on pt keyboard

2015-11-30 Thread Laura Creighton
In a message of Tue, 01 Dec 2015 02:57:15 +1100, Chris Angelico writes: >On Tue, Dec 1, 2015 at 2:10 AM, Random832 wrote: >> On 2015-11-30, Chris Angelico wrote: >>> Hmm. This could be part of the known issues with Tk (on which Idle >>> depends) and non-BMP characters, but a caret should be safe.

Question about code writing '% i, callback'

2015-11-30 Thread fl
Hi, I come across the following code snippet. for i in range(10): def callback(): print "clicked button", i UI.Button("button %s" % i, callback) The content inside parenthesis in last line is strange to me. "button %s" % i, callback That is, the writing looks like reco

Re: Python 3 virtualenvs

2015-11-30 Thread Carl Meyer
Hi Laura, On 11/29/2015 07:12 AM, Laura Creighton wrote: > pyenv is going away. python -m venv is the preferred way to get a venv > > https://bugs.python.org/issue25154 > > Of course if you try it, you may get: > > Error: Command '['/bin/python3.4', '-Im', 'ensurepip', > '--upgrade', '--def

Re: Question about code writing '% i, callback'

2015-11-30 Thread Zachary Ware
On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > The content inside parenthesis in last line is strange to me. > > "button %s" % i, callback https://docs.python.org/library/stdtypes.html#printf-style-string-formatting -- Zach -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about code writing '% i, callback'

2015-11-30 Thread Zachary Ware
On Mon, Nov 30, 2015 at 10:53 AM, Zachary Ware wrote: > On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: >> The content inside parenthesis in last line is strange to me. >> >> "button %s" % i, callback > > https://docs.python.org/library/stdtypes.html#printf-style-string-formatting Sorry, should have

Re: Question about code writing '% i, callback'

2015-11-30 Thread Ian Kelly
On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > I come across the following code snippet. > > for i in range(10): > def callback(): > print "clicked button", i > UI.Button("button %s" % i, callback) > > The content inside parenthesis in last line is strange to me. > > "button %s" % i

static variables

2015-11-30 Thread Ulli Horlacher
I try to to implement a "static variable" inside a function: def main(): a(1) a(2) a() print(a.x) if 'a.x' in globals(): print('global variable') if 'a.x' in locals(): print('local variable') def a(x=None): if not x is None: a.x = x print(':',a.x) main() When I run this code,

Re: Python 3 virtualenvs

2015-11-30 Thread Laura Creighton
In a message of Mon, 30 Nov 2015 09:32:27 -0700, Carl Meyer writes: >Hi Laura, >I don't know what you mean by this. Venv is intended to do _exactly_ >what virtualenv does, only better. Unless by "what virtualenv does" you >mean "also support Python 2." That is exactly what I mean. >> I think it

Re: Python 3 virtualenvs

2015-11-30 Thread Carl Meyer
On 11/30/2015 10:20 AM, Laura Creighton wrote: > In a message of Mon, 30 Nov 2015 09:32:27 -0700, Carl Meyer writes: >>> I think it is only meant to be used by people who want to install >>> packages but not site-wide, but I am not sure about that. >> >> I don't know what you mean by this either. I

Re: Caret key quits idle on pt keyboard

2015-11-30 Thread Terry Reedy
On 11/30/2015 11:13 AM, Laura Creighton wrote: In a message of Tue, 01 Dec 2015 02:57:15 +1100, Chris Angelico writes: On Tue, Dec 1, 2015 at 2:10 AM, Random832 wrote: On 2015-11-30, Chris Angelico wrote: Hmm. This could be part of the known issues with Tk (on which Idle depends) and non-BMP

Re: Python 3 virtualenvs

2015-11-30 Thread Jon Ribbens
On 2015-11-30, Carl Meyer wrote: > (Or maybe virtualenv will make the transition sooner, and you'll start > using venv under the hood for 3.3+ without even realizing it.) It does sound like that would be the ideal solution, and presumably can't be very hard if venv is supposed to do exactly what

Re: Question about code writing '% i, callback'

2015-11-30 Thread Terry Reedy
On 11/30/2015 11:44 AM, fl wrote: I come across the following code snippet. for i in range(10): def callback(): print "clicked button", i UI.Button("button %s" % i, callback) http://effbot.org/zone/default-values.htm Note that the above is an intentional example of com

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 11:44:44 AM UTC-5, fl wrote: > Hi, > > I come across the following code snippet. > > > > > > for i in range(10): > def callback(): > print "clicked button", i > UI.Button("button %s" % i, callback) > > > > > The content inside parenthesis in

Re: static variables

2015-11-30 Thread Terry Reedy
On 11/30/2015 12:15 PM, Ulli Horlacher wrote: I try to to implement a "static variable" inside a function: def main(): a(1) a(2) a() print(a.x) if 'a.x' in globals(): print('global variable') if 'a.x' in locals(): print('local variable') def a(x=None): if not x is None: a

Re: Python 3 virtualenvs

2015-11-30 Thread Laura Creighton
In a message of Mon, 30 Nov 2015 10:28:46 -0700, Carl Meyer writes: >So I agree that for now you should be sticking with virtualenv (I use it >too), but I hope you'll take another look at venv a few years down the >road, if you find yourself in a situation where all the interpreters you >need are

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 12:37:52 PM UTC-5, Terry Reedy wrote: > On 11/30/2015 11:44 AM, fl wrote: > > > I come across the following code snippet. > > > for i in range(10): > > def callback(): > > print "clicked button", i > > UI.Button("button %s" % i, callback) > > >

Re: Question about code writing '% i, callback'

2015-11-30 Thread Ian Kelly
On Mon, Nov 30, 2015 at 10:36 AM, fl wrote: > Thanks for the replies. Now, I have the following code: > > > > class buibutton(): > print 'sd' > def __nonzero__(self): >return False > > def Button(self, ii, callbackk): > callbackk() > return > UI=buibutton() > >

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 12:02:57 PM UTC-5, Ian wrote: > On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > > I come across the following code snippet. > > > > for i in range(10): > > def callback(): > > print "clicked button", i > > UI.Button("button %s" % i, callback) > > > > T

Re: static variables

2015-11-30 Thread BartC
On 30/11/2015 17:15, Ulli Horlacher wrote: def main(): a(1) a(2) a() print(a.x) if 'a.x' in globals(): print('global variable') if 'a.x' in locals(): print('local variable') Try this: if 'x' in a.__dict__: print('attribute of a') -- Bartc -- https://mail.python.org/mail

Is vars() the most useless Python built-in ever?

2015-11-30 Thread Steven D'Aprano
I'm trying to understand why vars() exists. Does anyone use it? Every time I try to use it, I find it doesn't quite do what I want. And even if it did, there are more obvious and/or correct alternatives. For instance, I want to check whether a particular name is an instance attribute. So first I

Re: static variables

2015-11-30 Thread Steven D'Aprano
On Tue, 1 Dec 2015 07:32 am, BartC wrote: > On 30/11/2015 17:15, Ulli Horlacher wrote: >> def main(): >>a(1) >>a(2) >>a() >>print(a.x) >>if 'a.x' in globals(): print('global variable') >>if 'a.x' in locals(): print('local variable') > > Try this: > > if 'x' in a.__di

Re: python response slow when running external DLL

2015-11-30 Thread jfong
jf...@ms4.hinet.net at 2015/11/29 UTC+8 10:55:28AM wrote: > > > . > > > . > > > #do the rest > > > var_status.set('Download...') > > > _thread.start_new_thread(td_download, ()) #must use threading > > > > > > def td_download(): > > > result = mydll.SayHello() > >

Re: I can't understand re.sub

2015-11-30 Thread Erik
On 30/11/15 08:51, Jussi Piitulainen wrote: Surely the straight thing to say is: >>> foo.replace(' CONTENT_PATH ', ' Substitute ') 'foo bar baz spam Substitute bar spam' Not quite the same thing (but yes, with a third argument of 1, it would be). But there was no guarantee of spaces

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-11-30 Thread fl
On Wednesday, June 24, 2015 at 8:17:08 PM UTC-4, Chris Angelico wrote: > On Thu, Jun 25, 2015 at 9:52 AM, fl wrote: > > The reason is that list implements __iadd__ like this (except in C, not > > Python): > > > > class List: > > def __iadd__(self, other): > > self.extend(other) > >

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-11-30 Thread MRAB
On 2015-12-01 02:14, fl wrote: On Wednesday, June 24, 2015 at 8:17:08 PM UTC-4, Chris Angelico wrote: On Thu, Jun 25, 2015 at 9:52 AM, fl wrote: > The reason is that list implements __iadd__ like this (except in C, not Python): > > class List: > def __iadd__(self, other): > self.ex

Re: Is vars() the most useless Python built-in ever?

2015-11-30 Thread Josef Pktd
On Monday, November 30, 2015 at 8:01:14 PM UTC-5, Steven D'Aprano wrote: > I'm trying to understand why vars() exists. Does anyone use it? > > Every time I try to use it, I find it doesn't quite do what I want. And even > if it did, there are more obvious and/or correct alternatives. > > For inst

Re: Generate config file from template using Python search and replace.

2015-11-30 Thread Mr Zaug
On Monday, November 30, 2015 at 4:14:48 AM UTC-5, Peter Otten wrote: > Mr Zaug wrote: > > > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: > >> Mr Zaug wrote: > >> > >> > When I run this script on OS X El Capitan, I see, > >> > > >> > # permission sensitive cache > >> >

Re: I can't understand re.sub

2015-11-30 Thread Jussi Piitulainen
Erik writes: > On 30/11/15 08:51, Jussi Piitulainen wrote: [- -] >> If you wish to, >> say, replace "spam" in your foo with "REDACTED" but leave it intact in >> "May the spammer be prosecuted", a regex might be attractive after all. > > But that's not what the OP said they wanted to do. They said >

Re: Is vars() the most useless Python built-in ever?

2015-11-30 Thread Rick Johnson
On Monday, November 30, 2015 at 7:01:14 PM UTC-6, Steven D'Aprano wrote: > I'm trying to understand why vars() exists. Does anyone use it? I think your "mental dilemma" stems from the fact that python was originally created to be an easy language for noobs to learn (which it still mostly is), ho

Pylint 1.5.0 / Astroid 1.4.1 released

2015-11-30 Thread Claudiu Popa
Hello, I'm happy to announce you the release of Pylint 1.5.0, respectively Astroid 1.4.1. It's been over a year since the last major release and the amount of changes that were brought into pylint in this time is humongous, with over 30 new checks and tons of bug fixes. I would like to use this

Re: Is vars() the most useless Python built-in ever?

2015-11-30 Thread eryk sun
On Mon, Nov 30, 2015 at 7:00 PM, Steven D'Aprano wrote: > Either way, vars() doesn't solve the problem. What problem does it solve? vars() used to be the way to list local variables. >From 4 May 1994, Python 1.0.2 [1]: vars() returns a dictionary containing the local variables; vars(m)

Re: Is vars() the most useless Python built-in ever?

2015-11-30 Thread Marko Rauhamaa
Rick Johnson : > python was originally created to be an easy language for noobs to > learn Really? That's would be a silly objective for a programming language. > many a noob has been stumped So? You have to first placate the experts and the "noobs" will follow. Marko -- https://mail.python