Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Jan 21, 2016 7:31 AM, "Charles T. Smith" wrote: > > What does "from (module) import (func)" do? Approximately equivalent to: import module func = module.func Except that it doesn't bind "module" to anything. > Please don't tell me that I shouldn't ask because

Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Thu, Jan 21, 2016 at 8:12 AM, Charles T. Smith wrote: >>> would you explain to me why I get this: >>> >>> (PDB)hexdump(msg) >>> *** NameError: name 'hexdump' is not defined >> >> Probably because the name 'hexdump' is not defined. > > > If indeed it's not

Re: parallel (concurrent) eventlet

2016-01-18 Thread Ian Kelly
On Mon, Jan 18, 2016 at 8:03 AM, David Gabriel wrote: > Dears, > > Let me add one more detail: When I add these two lines to check whether my > modules are monkey_patched or not I get *False* as a result. > I think it is strange to get this result since I patched my modules

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Ian Kelly
On Mon, Jan 18, 2016 at 9:51 AM, Chris Angelico wrote: > On Tue, Jan 19, 2016 at 3:28 AM, Charles T. Smith >> Okay, I think I understand it now: >> >> (PDB)type (int) >> >> >> (PDB)type (float) >> > > And that's pretty strong evidence right there! So the next question > is...

Re: Pyton install Landmine

2016-01-16 Thread Ian Kelly
On Jan 16, 2016 3:02 AM, "JeffP" wrote: > > Hi > I installed pyth3.5 on my Windows machine and had some complications trying to connect other components. > I installed to the default directory chosen by the installer but that included a folder with an embedded space in the name.

Re: Keen eyes

2016-01-16 Thread Ian Kelly
On Jan 17, 2016 12:16 AM, "Steven D'Aprano" wrote: > > On Sun, 17 Jan 2016 10:25 am, jonas.thornv...@gmail.com wrote: > > > double use of j in two different functions > > Are you using a global variable called "j" as a loop variable? That sounds > like a terrible idea. > >

Re: wxpython strange behaviour

2016-01-15 Thread Ian Kelly
On Fri, Jan 15, 2016 at 10:05 AM, Shiva Upreti wrote: > https://gist.github.com/anonymous/4baa67aafd04555eb4e6 > > I wrote the above code to display a toasterbox, and I didnt want it to > display any frames on the screen, just a toasterbox. The problem with this > code

Re: Stop writing Python 4 incompatible code

2016-01-14 Thread Ian Kelly
On Thu, Jan 14, 2016 at 8:52 AM, Rick Johnson wrote: > So you're suggesting that GvR *WILLINGLY* left a global, and > well established giant, to work for a tiny start-up because > his bosses refused to switch from Python2 to (his new baby) > Pyhton3? > > So, let me

Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Ian Kelly
On Wed, Jan 13, 2016 at 3:19 AM, Chris Angelico wrote: > You're quite probably right that obfuscating the display is security > theatre; but it's the security theatre that people are expecting. If > you're about to enter your credit card details into a web form, does > it really

Re: I'm missing something here...

2016-01-12 Thread Ian Kelly
On Mon, Jan 11, 2016 at 6:04 PM, Skip Montanaro wrote: > Sorry, I should have been explicit. prob_dates (the actual argument of the > call) is a set. As far as I know pylint does no type inference, so pylint > can't tell if the LHS and RHS of the |= operator are

Re: When I need classes?

2016-01-12 Thread Ian Kelly
On Mon, Jan 11, 2016 at 5:53 PM, Bernardo Sulzbach wrote: > I have never gone "seriously OO" with Python though. I never wrote > from scratch an application with more than 10 classes as far as I can > remember. However, I would suppose that the interpreter can handle >

Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict

2016-01-12 Thread Ian Kelly
On Tue, Jan 12, 2016 at 10:12 AM, Terry Reedy wrote: > Using the values views at intended (as an iterable): > dv = d.values() next(iter(dv)) > 1 Good coding practice also dictates that whenever next is called, the potential StopIteration exception must be caught

Re: What use is '__reduce__'?

2016-01-08 Thread Ian Kelly
As you found by searching, __reduce__ is used to determine how instances of the class are pickled. If the example you're using doesn't do any pickling, then it's not really relevant to the example. It's probably included so that it won't be missed when the code is copied. On Fri, Jan 8, 2016 at

Re: What is the fastest way to do 400 HTTP requests using requests library?

2016-01-05 Thread Ian Kelly
On Tue, Jan 5, 2016 at 10:02 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> Maybe they're stress-testing a web server, or they just want to download >> things in a rush. > > They're stress-testing a web server through a tor proxy? This sounds >

Re: What is the fastest way to do 400 HTTP requests using requests library?

2016-01-04 Thread Ian Kelly
On Mon, Jan 4, 2016 at 4:38 PM, Steven D'Aprano wrote: > On Tue, 5 Jan 2016 07:50 am, livems...@gmail.com wrote: > >> So what is the fastest way to make 400 HTTP requests using "requests" >> library and also using tor proxy? > > > Since this will be I/O bound, not CPU bound,

Re: Is there a way importing a string object?

2016-01-04 Thread Ian Kelly
On Mon, Jan 4, 2016 at 5:49 PM, wrote: > For example, > > name = "test" # test.py is a module's file > import name Yes, use the importlib.import_module function. -- https://mail.python.org/mailman/listinfo/python-list

Re: Consistent error

2016-01-03 Thread Ian Kelly
On Sun, Jan 3, 2016 at 8:59 AM, wrote: > Thanks Chris! > Don't worry about the indent, will fix it > I've rewritten it to this- > > def get_algorithm_result( numlist ): >> largest = numlist[0] >> i = 1 >> while ( i < len(numlist) ): > i = i + 1 >>if ( largest

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 9:58 AM, Charles T. Smith <cts.private.ya...@gmail.com> wrote: > On Wed, 30 Dec 2015 08:35:57 -0700, Ian Kelly wrote: > >> On Dec 30, 2015 7:46 AM, "Charles T. Smith" >> <cts.private.ya...@gmail.com> wrote: >>> As is

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 3:54 PM, Charles T. Smith <cts.private.ya...@gmail.com> wrote: > On Wed, 30 Dec 2015 13:40:44 -0700, Ian Kelly wrote: > >> On Wed, Dec 30, 2015 at 9:58 AM, Charles T. Smith >>> The problem is that then triggers the __getitem__() method and

Re: Newbie: How to convert a tuple of strings into a tuple of ints

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 3:46 PM, wrote: > How do I get from here > > t = ('1024', '1280') > > to > > t = (1024, 1280) Deja vu: https://mail.python.org/pipermail/python-list/2015-December/701017.html -- https://mail.python.org/mailman/listinfo/python-list

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Dec 30, 2015 7:46 AM, "Charles T. Smith" wrote: > As is so often the case, in composing my answer to your question, I discovered > a number of problems in my class (e.g. I was calling __getitem__() myself!), > but > I'm puzzled now how to proceed. I thought the

Re: Importing constantly changing variables

2015-12-26 Thread Ian Kelly
On Sat, Dec 26, 2015 at 8:14 AM, wrote: > As you can see, I want the program to print all values each 5 seconds. > When I run the file "main.py" it does print values every 5 seconds, BUT when > I manually change > the values (e.g. airTemperture = 30 instead of 24) and

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-22 Thread Ian Kelly
On Tue, Dec 22, 2015 at 8:17 AM, Grant Edwards wrote: > On 2015-12-21, Steven D'Aprano wrote: > >> So as far as I am concerned, if changes of subject line breaks threading for >> you, so sad, too bad. Go without threading or use a better mail client.

Re: Ignore error with non-zero exit status

2015-12-21 Thread Ian Kelly
On Sun, Dec 20, 2015 at 3:46 PM, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Mon, Dec 21, 2015 at 8:22 AM, Thomas 'PointedEars' Lahn >> wrote: > > It is supposed to be an attribution *line*, _not_ an attribution novel. > Also, the

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 1:58 PM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Ian Kelly <ian.g.ke...@gmail.com> writes: >> This isn't just a Usenet group; it's also a mailing list, and many >> MUAs rely on the Subject header for proper threading. > &

Re: Ignore error with non-zero exit status

2015-12-21 Thread Ian Kelly
On Dec 21, 2015 4:55 PM, "Terry Reedy" wrote: > > Nothing has changed since except for > https://www.python.org/dev/peps/pep-0498/ > already added to 3.6. https://xkcd.com/927/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 4:24 PM, Jon Ribbens wrote: > On 2015-12-21, Steven D'Aprano wrote: >> The whole purpose of the change of subject is to indicate in a human-visible >> way that the subject of the thread has changed, i.e. that it is a new

Re: Catogorising strings into random versus non-random

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 9:40 AM, duncan smith wrote: > Finite state machine / transition matrix. Learn from some English text > source. Then process your strings by lower casing, replacing underscores > with spaces, removing trailing numeric characters etc. Base your score

Re: Should stdlib files contain 'narrow non breaking space' U+202F?

2015-12-17 Thread Ian Kelly
On Thu, Dec 17, 2015 at 4:05 PM, Mark Lawrence wrote: > The culprit character is hidden between "Issue #" and "20540" at line 400 of > C:\Python35\Lib\multiprocessing\connection.py. > https://bugs.python.org/issue20540 and > https://hg.python.org/cpython/rev/125c24f47f3c

Re: error reading api with urllib

2015-12-16 Thread Ian Kelly
On Wed, Dec 16, 2015 at 3:12 PM, John Gordon wrote: > In <9aa21642-765b-4666-8c66-a6dab9928...@googlegroups.com> > simian...@gmail.com writes: > >> Bad Request >> b'' > > > That probably means you aren't using one of the recognized methods > (i.e. GET, POST, etc.) > > It

Re: error reading api with urllib

2015-12-16 Thread Ian Kelly
On Tue, Dec 15, 2015 at 7:46 PM, Simian wrote: > I added > > except urllib.error.HTTPError as e: > print('HTTP Errpr') > print('Error code: ', e.code) > > to my try and I recieve... > > 400: ('Bad Request', > 'Bad request syntax or unsupported method'), > > but

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 9:20 AM, Pavlos Parissis <pavlos.paris...@gmail.com> wrote: > On 15/12/2015 05:11 μμ, Ian Kelly wrote: >> On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis >> <pavlos.paris...@gmail.com> wrote: >>> Hi, >>> >>> I n

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis wrote: > Hi, > > I need to store values for metrics and return the average for some > and the sum for the rest. Thus, I thought I could extend > collections.Counter class by returning averages for some keys. Leave

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 10:43 AM, Pavlos Parissis wrote: >> If you want your metrics container to act like a dict, then my >> suggestion would be to just use a dict, with pseudo-collections for >> the values as above. >> > > If I understood you correctly, you are saying

Re: Try: rather than if :

2015-12-14 Thread Ian Kelly
On Mon, Dec 14, 2015 at 4:48 PM, Vincent Davis wrote: > On Mon, Dec 14, 2015 at 4:14 PM, Cameron Simpson wrote: > >> First, notice that the code inside the try/except _only_ fetches the >> attribute. Your version calls the "write" attribute, and also

Re: Try: rather than if :

2015-12-14 Thread Ian Kelly
On Mon, Dec 14, 2015 at 3:38 PM, Vincent Davis wrote: > In the code below try is used to check if handle has the attribute name. It > seems an if statement could be used. Is there reason one way would be > better than another? http://www.oranlooney.com/lbyl-vs-eafp/ --

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 1:05 PM, KP wrote: > On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: >> In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: >> >Hi all, >> > >> > f = open("stairs.bin", "rb") >> > data = list(f.read(16)) >> >

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 12:45 PM, wrote: > Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > > returns > > ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', > '\x00', '\x00', '\x00', '\x00',

Re: Calling a list of functions

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 10:26 AM, Ganesh Pal wrote: > Hi Team, > > Iam on linux and python 2.7 . I have a bunch of functions which I > have run sequentially . > I have put them in a list and Iam calling the functions in the list as > shown below , this works fine for me ,

Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:10 AM, ICT Ezy wrote: > Dear All, > Very Sorry for the my mistake here. I code here with mu question ... > > My Question: > > A,B=C,D=10,11 > print(A,B,C,D) > #(10,11,10,11) --> This is OK! > > a=1; b=2 > a,b=b,a > print(a,b) > # (1,2) --> This is OK!

Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch wrote: > Assigning goes from right to left: > > x,y=y,x=2,3 > > <=> > > y, x = 2, 3 > x, y = y, x > > Otherwise the assignment x, y = y, x would not make any sense, since x and y > haven't any values yet. > > And the execution

Re: python 351x64

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:30 AM, Jay Hamm wrote: > Hi > > I was trying to use your windows version of python 3.5.1 x64. > > It has a conflict with a notepad++ plugin NppFTP giving > api-ms-win-crt-runtime-I1-1-0.dll error on start up. > > This seems pretty well documented on

Re: Hello

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 11:43 AM, Seung Kim wrote: > See message below. > > On Fri, Dec 11, 2015 at 1:13 PM, Seung Kim wrote: > >> I would like to have Python 3.5.1 MSI installer files for both 32-bit and >> 64-bit so that I can deploy the

Re: Accessing container's methods

2015-12-08 Thread Ian Kelly
On Tue, Dec 8, 2015 at 3:37 PM, Erik wrote: > On 08/12/15 19:02, Thomas 'PointedEars' Lahn wrote: >> >> Erik wrote: >> >> Please fix, Erik #75656. > > > Fixed(*) [SNIP] > (*) In the sense that it's not going to change ;) Then I think you mean "Working as

Re: Accessing container's methods

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 11:10 AM, Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to access > methods from A. > . > A highly contrived example, where I'm setting up an outer class in a Has-a > relationship, containing a

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:07 PM, wrote: > Hello all! Just started getting into Python, and am very excited about the > prospect. > > I am struggling on some general concepts. My past experience with > server-side code is mostly limited to PHP and websites. I have some

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:40 PM, Chris Angelico wrote: > So that's a quick potted summary of why the URLs don't reflect the > language used. Python is event-driven, but instead of defining events > at the file level, the way PHP does, they're defined at the function > level. Of

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 3:27 PM, wrote: > Thank you all! > > Okay, the concept of a WSGI along with a framework provides insight on my > main questions. > > In regards to Chris's statement: "It openly and honestly does NOT reset its > state between page requests" > > With

Re: Issue

2015-12-07 Thread Ian Kelly
On Sun, Dec 6, 2015 at 5:16 PM, Steven D'Aprano wrote: > Oh, I can make one guess... if you're using Windows XP, I'm afraid that > Python 3.5 is not supported. You'll have to either downgrade to Python 3.4, > or upgrade to Windows 7 or higher, or another operating system.

Re: increment/decrement operators

2015-12-07 Thread Ian Kelly
On Dec 5, 2015 10:21 AM, "BartC" wrote: > > > The latter is not the same. Some of the differences are: > > * ++ and -- are often inside inside expressions and return values (unlike x+=1 in Python) > > * x++ and x-- return the /current/ value of x, unlike x+=1 even if it

Re: [Python-ideas] Missing Core Feature: + - * / | & do not call __getattr__

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 7:20 AM, Stephan Sahm wrote: > Dear all, > > I just stumbled upon a very weird behaviour of python 2 and python 3. At > least I was not able to find a solution. > > The point is to dynamically define __add__, __or__ and so on via __getattr__ > (for

Re: Frozen apps (py2exe, cx_freeze) built with Python 3.5

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 10:21 AM, d...@forestfield.co.uk wrote: > Python 3.5 will not run under Windows XP, but what about applications created > using py2exe or cx_freeze under Windows 7, 8 or 10, is there any knowledge of > whether they will run under XP? I wouldn't

Re: [Python-ideas] Using functools.lru_cache only on some arguments of a function

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 2:44 PM, Bill Winslow wrote: > This is a question I posed to reddit, with no real resolution: > https://www.reddit.com/r/learnpython/comments/3v75g4/using_functoolslru_cache_only_on_some_arguments/ > > The summary for people here is the following: > >

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Ian Kelly
On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: > Now *I* am confused. > > Shouldn't it be > > ", ".join(['1', '2', '4', '8', '16']) > > instead? Without any importing? That would be the normal way to write it. The FAQ entry is suggesting the string module function as

Re: static variables

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 7:41 AM, Antoon Pardon wrote: > Op 02-12-15 om 14:11 schreef Steven D'Aprano: >> On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote: >> >>> If you want your arguments to be taken seriously, then you better should. >>> If you use an argument when

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 10:36 AM, Keith Thompson wrote: > Juha Nieminen writes: >> In comp.lang.c++ Steve Hayes wrote: >>> You download things FROM a computer, you upload them TO a computer. >> >> It's a matter of perspective. If a

Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 1:44 PM, Dylan Riley wrote: > hi ian what would be the correct code to use in this situation then because > as far as i am aware the elements of my list should be printed as whole > elements and not just characters of the elements.

Re: static variables

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 9:30 AM, Antoon Pardon <antoon.par...@rece.vub.ac.be> wrote: > Op 02-12-15 om 15:15 schreef Ian Kelly: >> On Wed, Dec 2, 2015 at 7:41 AM, Antoon Pardon >> <antoon.par...@rece.vub.ac.be> wrote: >>> Op 02-12-15 om 14:11 schreef Steven D'Apra

Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 12:58 PM, Dylan Riley wrote: > hi all, > I have been trying to figure out all day why my code is printing single > characters from my list when i print random elements using random.choice the > elements in the list are not single characters for

Re: Question about split method

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 2:37 PM, Robert wrote: > Hi, > > I learn split method online. When I try to run the line with ss1 beginning, > I don't understand why its output of ss1 and ss2. I have check the help > about split. It looks like that it is a numpy method. > What is the

Re: Python 3.5.0: python.exe is not a valid Windows 32 application

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:09 PM, wrote: > Hi. > > https://mail.python.org/pipermail/python-dev/2015-July/140823.html > Python 3.5 was dropped the support Windows XP and 2003. > > > > It's just an aside, but Python 3.5.1 works on my customized Windows 2000 :P >

Re: Subclassing tuple and introspection

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:32 PM, Joseph L. Casale wrote: > I need to return a collection of various types, since python doesn't > have the terse facility of extension methods like C#, subclassing tuple > and adding a method seems like a terse way to accommodate this. If

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-01 Thread Ian Kelly
On Tue, Dec 1, 2015 at 12:49 PM, Steve Hayes wrote: > On Tue, 1 Dec 2015 03:19:39 +0100, "Skybuck Flying" > wrote: > >>Hello, >> >>The question is: >> >>Is Microsoft Windows secretly downloading childporn to your computer ?! > > You download things

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

2015-12-01 Thread Ian Kelly
On Tue, Dec 1, 2015 at 2:32 PM, Denis McMahon wrote: > On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: > >> In the case of: >> >> tup[1] += [6, 7] >> >> what it's trying to do is: >> >> tup[1] = tup[1].__iadd__([6, 7]) >> >> tup[1] refers to a list, and the

Re: "Downloading"

2015-12-01 Thread Ian Kelly
On Tue, Dec 1, 2015 at 5:05 PM, Chris Angelico wrote: > On Wed, Dec 2, 2015 at 6:05 AM, Random832 wrote: >> On 2015-12-01, Steve Hayes wrote: >>> You download things FROM a computer, you upload them TO a computer. >> >> I'm a

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

2015-12-01 Thread Ian Kelly
On Dec 1, 2015 1:36 PM, "Rick Johnson" wrote: > > On Tuesday, December 1, 2015 at 1:55:59 AM UTC-6, Steven D'Aprano wrote: > > Python was never intended to be "merely" a teaching language. I think > > Guido's original vision was for it to be a glue language

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

2015-12-01 Thread Ian Kelly
On Mon, Nov 30, 2015 at 7:44 PM, Dennis Lee Bieber wrote: > On Mon, 30 Nov 2015 10:55:23 -0800 (PST), fl declaimed > the following: > >>Thanks Ian. I created the class because I want to use the original example >>line >> >> UI.Button("button %s" % i,

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.

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 >

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 2:05 PM, Antoon Pardon <antoon.par...@rece.vub.ac.be> wrote: > Op 25-11-15 om 21:39 schreef Ian Kelly: >> On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon >> <antoon.par...@rece.vub.ac.be> wrote: >>> I don't know what you are talking

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 5:52 PM, Random832 wrote: > On 2015-11-25, Ben Finney wrote: >> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different >> than in ‘cartesian_point = (3, 2)’. >> >> Whereas the ‘2’ in ‘test_scores = [2,

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 7:25 PM, Chris Angelico wrote: > On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: >> (Note that nothing in the documentation I can find actually _guarantees_ >> that a Python implementation will only have one unique empty tuple,

Re: list slice and generators

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 10:44 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote: >>> elif name in METRICS_AVG: >> # writing a function that calculates the average without >>

Re: list slice and generators

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote: > to get down to one intermediate list. Avoiding the last one is a bit tricky: > > metrics = (converter(x.metric(name)) for x in self._server_per_proc) > metrics = (x for x in metrics if x is not None) > try: > # if there

Re: What is a function parameter =[] for?

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon wrote: > I don't know what you are talking about. The first thing I have argued > is that () is a literal. Then I have expaned that to that something > like (3, 5, 8) is a literal. I never argued that tuple expressions

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Ian Kelly
On Wed, Nov 25, 2015 at 10:18 AM, BartC wrote: >> We have no way of evaluating their power or simplicity, >> since they are not available to us. > > I'll see if I can rustle up a comparison so that Python users can see what > they're missing! Unless you're going to make the

Re: Bi-directional sub-process communication

2015-11-24 Thread Ian Kelly
On Mon, Nov 23, 2015 at 10:25 PM, Cameron Simpson wrote: > Then #3. I would have a common function/method for submitting a request to > go to the subprocess, and have that method return an Event on which to wait. > Then caller then just waits for the Event and collects the data.

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 1:54 PM, Antoon Pardon <antoon.par...@rece.vub.ac.be> wrote: > Op 24-11-15 om 20:15 schreef Ian Kelly: > >>> But no matter what you want to call it. The dis module shows that >>> -42 is treated in exactly the same way as 42, which is tr

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 9:41 AM, Antoon Pardon wrote: > Op 24-11-15 om 16:48 schreef Chris Angelico: >> () is not a literal either. > > The byte code sure suggests it is. > > Take the following code: > > import dis > > def f(): > i = 42 > t = () > l = [] > >

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon <antoon.par...@rece.vub.ac.be> wrote: > Op 24-11-15 om 17:56 schreef Ian Kelly: > >> >>> So on what grounds would you argue that () is not a literal. >> >> This enumerates exactly what literals are in Python: &g

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 10:53 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon > <antoon.par...@rece.vub.ac.be> wrote: >> Op 24-11-15 om 17:56 schreef Ian Kelly: >> >>> >>>> So on wh

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 11:45 AM, Antoon Pardon wrote: > I think limiting literals to lexical tokens is too limited. Sure we > can define them like that in the context of the python grammar, but > I don't see why we should limit ourselves to such a definition outside

Re: What is a function parameter =[] for?

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 12:00 PM, Random832 wrote: > On 2015-11-24, Chris Angelico wrote: >> Probably the grammar. In other words, it's part of the language's very >> definition. > > Then the definition is wrong. I think "literal" is a word whose meaning

Re: Bi-directional sub-process communication

2015-11-23 Thread Ian Kelly
On Mon, Nov 23, 2015 at 10:54 AM, Israel Brewster wrote: > Concern: Since the master process is multi-threaded, it seems likely enough > that multiple threads on the master side would make requests at the same > time. I understand that the Queue class has locks that make

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-23 Thread Ian Kelly
On Mon, Nov 23, 2015 at 1:23 AM, Chris Angelico wrote: > def latearg(f): > tot_args = f.__code__.co_argcount > min_args = tot_args - len(f.__defaults__) > defs = f.__defaults__ > # With compiler help, we could get the original text as well as something > #

Re: Bi-directional sub-process communication

2015-11-23 Thread Ian Kelly
On Mon, Nov 23, 2015 at 12:55 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Mon, Nov 23, 2015 at 10:54 AM, Israel Brewster <isr...@ravnalaska.net> > wrote: >> Concern: Since the master process is multi-threaded, it seems likely enough >> that multiple threads

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-21 Thread Ian Kelly
On Sat, Nov 21, 2015 at 1:46 AM, Chris Angelico wrote: > On Sat, Nov 21, 2015 at 7:38 PM, Todd wrote: >> Rather than a dedicated syntax, might this be something that could be >> handled by a built-in decorator? >> >> Maybe something like: >> >> @late_binding

Re: What is a function parameter =[] for?

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 9:24 AM, Chris Angelico wrote: > The cases where that's not true are usually ones that are more like > C++ overloaded functions: > > def next(iter): > return iter.__next__() > def next(iter, default): > try: return iter.__next__() > except

Re: What is a function parameter =[] for?

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 5:39 AM, BartC wrote: > * The persistent nonsense that somehow [] is mutable (what happens is that > [] is assigned to a variable, and /that/ is mutable) (And I will probably > get some flak now because 'assign' and 'variable' are meaningless in > Python!)

Re: What is a function parameter =[] for?

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 5:28 AM, Marko Rauhamaa wrote: > The Ackermann function really is an esoteric example, but the other > example that has been discussed here can make practical use of the > default-value semantics: > >[ lambda x: i * x for i in range(4) ] > > which is

Re: What is a function parameter =[] for?

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 9:31 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: > Ian Kelly <ian.g.ke...@gmail.com>: > >> On Fri, Nov 20, 2015 at 5:28 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: >>> One could argue that you should always use a sentinel object f

Re: How To Create A Endles List Of Lists In Python...???

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 11:16 AM, wrote: > Dana petak, 20. studenoga 2015. u 18:16:52 UTC+1, korisnik Denis McMahon > napisao je: >> On Fri, 20 Nov 2015 08:43:04 +0100, HKRSS wrote: >> >> > Thanks In Advance, Robert...;) >> >> Just keep appending child lists to parent

Re: error help import random

2015-11-20 Thread Ian Kelly
On Fri, Nov 20, 2015 at 10:57 AM, Peter Otten <__pete...@web.de> wrote: > Dylan Riley wrote: > >> input("\nPress enter to see your fortune") > > Make sure that you run your code with Python 3, not Python 2. Or if you must use Python 2, use raw_input() instead of input(). >> fortune =

Re: What is a function parameter =[] for?

2015-11-19 Thread Ian Kelly
On Thu, Nov 19, 2015 at 11:26 AM, Mark Lawrence wrote: > To summarize, it once again shows that you haven't got the faintest idea > what you're talking about. You're now in a very exclusive club with the RUE > and Nick the Greek, the world's leading webmaster. Eh.

Re: What is a function parameter =[] for?

2015-11-19 Thread Ian Kelly
On Thu, Nov 19, 2015 at 12:19 PM, Chris Angelico wrote: > But you're > saying that it "simply substitute[s] the expression", which would mean > that "func()" is exactly the same as "func(y)". A function default > argument is therefore able to STEAL STUFF FROM THE CALLER'S SCOPE.

Re: What is a function parameter =[] for?

2015-11-19 Thread Ian Kelly
On Nov 19, 2015 5:31 PM, "Steven D'Aprano" wrote: > > [Aside: there is some ambiguity here. If I say "a reference to B", I > actually mean a reference to the object referenced to by B. I don't mean a > reference to the *name* B. Python doesn't support that feature: names are

Re: Unsuccessful installation

2015-11-19 Thread Ian Kelly
On Thu, Nov 19, 2015 at 12:45 PM, Kaufman, Stan wrote: > Python would not run on this Windows XP computer. After four attempts at > "change/remove" it still gives the same message: > > [cid:image001.png@01D122D0.93CC3270] > > The first trip through "change/remove" appeared to

Re: Dabbling in web development

2015-11-19 Thread Ian Kelly
On Thu, Nov 19, 2015 at 2:53 PM, bSneddon wrote: > I know there are a plethora of web frameworks out there for Python and to be > serious about website developement I should learn on like Django. Really > thought, I just want to dabble and do some easy stuff. Does

Re: What is a function parameter =[] for?

2015-11-19 Thread Ian Kelly
On Thu, Nov 19, 2015 at 5:45 AM, Steven D'Aprano wrote: > But if you want the default value to be evaluated exactly once, and once > only, there is no real alternative to early binding. You could use a global > variable, of course, but that is no solution -- that's a problem

Re: What is a function parameter =[] for?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 5:34 PM, fl wrote: > After I try with > > list1 = eList(12, [2]) > > and > > list1 = eList(12) > > it gives me new surprises. Even though I delete list1, the subsequent > list1 = eList(12) > will remember the number of '12' of the previous sequence. This

<    3   4   5   6   7   8   9   10   11   12   >