Re: Books?

2012-08-22 Thread Michael Poeltl
I would recommend "Dive into Python3" just goole-search "dive into python3" filetype:pdf and you got it! regards Michael * Anonymous Group [2012-08-22 03:40]: > What books do you recomend for learning python? Preferably free and/or > online. > -- > http://mail.python.org/mailman/listinfo/pyth

Re: asking

2012-08-22 Thread mingqiang hu
I mean any of "a","b","c" in string "adfbdfc" makes the statement true,can I not use a function? suppose I got lots of substring let's say s1="a",s2="b",s3="c" ...,not wrap them as a tuple or a list , just make the statement as simple as possible to check if any of the value is the substring of S

Re: something about split()???

2012-08-22 Thread Mark Lawrence
On 22/08/2012 06:46, Terry Reedy wrote: On 8/21/2012 11:43 PM, mingqiang hu wrote: why filter is bad when use lambda ? Inefficient, not 'bad'. Because the equivalent comprehension or generator expression does not require a function call. A case of premature optimisation? :) -- Cheers. Mar

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-22 Thread Guillaume Comte
Le mercredi 22 août 2012 04:10:43 UTC+2, Dennis Lee Bieber a écrit : > On Tue, 21 Aug 2012 10:00:28 -0700 (PDT), Guillaume Comte > > declaimed the following in > > gmane.comp.python.general: > > > > A later follow-up > > > Unfortunatly, my_socket.bind((src_addr, 1)) doesn't work. I get

Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-22 Thread Mark Lawrence
On 22/08/2012 07:25, Bob Martin wrote: in 679182 20120821 181439 Dennis Lee Bieber wrote: On Tue, 21 Aug 2012 08:07:33 +0200, Alex Strickland declaimed the following in gmane.comp.python.general: On 2012/08/17 12:42 AM, Madison May wrote: As a lurker, I agree completely with Chris's sentim

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Andreas Perstinger
On 22.08.2012 08:21, Santosh Kumar wrote: with open(givenfile) as file: # List to store the capitalised lines. lines = [] for line in file: # Split words by spaces. words = line.split(' ') The last element in your "words" list will still have a newline characte

Re: Books?

2012-08-22 Thread Mark Lawrence
On 22/08/2012 02:36, Anonymous Group wrote: What books do you recomend for learning python? Preferably free and/or online. Search for the Alan Gauld tutorial. I've never used it myself, but OTOH I've never heard anybody complain about it!!! As someone else has already mentioned it, I'd hig

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Chris Angelico
On Wed, Aug 22, 2012 at 4:21 PM, Santosh Kumar wrote: > Purpose of the script: > To capitalize the first letter of any word in a given file, leaving > words which have 3 or less letters. > > Bugs: > I know it has many bugs or/and it can be improved by cutting down the > code, but my current focus

Re: Reimporting modules, and sandboxing?

2012-08-22 Thread Mark Lawrence
On 21/08/2012 22:51, Dan Stromberg wrote: I know I've seen this discussed before, and I came away from observing the discussion thinking "Python doesn't do that very well...", but we have some people here who really would like to do this, and I need to better understand the pros and cons now. Is

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Hans Mulder
On 22/08/12 08:21:47, Santosh Kumar wrote: > Here is the script I am using: > > from os import linesep > from string import punctuation > from sys import argv > > script, givenfile = argv > > with open(givenfile) as file: > # List to store the capitalised lines. > lines = [] > for li

Re: asking

2012-08-22 Thread Dave Angel
On 08/22/2012 03:17 AM, mingqiang hu wrote: > I mean any of "a","b","c" in string "adfbdfc" makes the statement true,can > I not use a function? suppose I got lots of substring let's say > s1="a",s2="b",s3="c" ...,not wrap them as a tuple or a list , just make the > statement as simple as possibl

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-22 Thread Guillaume Comte
I've managed to build the IP header. I've put the source and destination addresses in this header but it doesn't change the real source address... I'm trying to read the ping source code but I'm lost... -- http://mail.python.org/mailman/listinfo/python-list

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-22 Thread Hans Mulder
On 22/08/12 09:29:37, Guillaume Comte wrote: > Le mercredi 22 août 2012 04:10:43 UTC+2, Dennis Lee Bieber a écrit : >> On Tue, 21 Aug 2012 10:00:28 -0700 (PDT), Guillaume Comte >> declaimed the following in >> gmane.comp.python.general: >> A later follow-up >>> Unfortunately, my_socket.bind

Re: How to set the socket type and the protocol of a socket using create_connection?

2012-08-22 Thread Guillaume Comte
Le mercredi 22 août 2012 11:03:11 UTC+2, Hans Mulder a écrit : > > On my laptop, 0 appears to be the only port number that bind accepts > > for a raw socket. Other numbers I tried all raise "socket.error: > > [Errno 49] Can't assign requested address". > > > > But this might depend on your

Re: asking

2012-08-22 Thread alex23
On 08/22/2012 03:17 AM, mingqiang hu wrote: > I mean any of "a","b","c" in string "adfbdfc"  makes the statement true,can > I not use a function? any(map(string.__contains__, substrings)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Books?

2012-08-22 Thread Jamie Paul Griffin
[ Mark Lawrence wrote on Wed 22.Aug'12 at 8:43:58 +0100 ] > On 22/08/2012 02:36, Anonymous Group wrote: > > What books do you recomend for learning python? Preferably free and/or > > online. > > > > Search for the Alan Gauld tutorial. I've never used it myself, but OTOH > I've never heard anyb

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Kamil Kuduk
> Purpose of the script: > To capitalize the first letter of any word in a given file, leaving > words which have 3 or less letters. First or all? If first and this is the only purpose of the script you can easily use sed: less file.txt | sed -e "s/\b\([a-z]\{4,\}\)/\u\1/g" -- http://mail.python.

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Chris Angelico
On Wed, Aug 22, 2012 at 8:28 PM, Kamil Kuduk wrote: >> Purpose of the script: >> To capitalize the first letter of any word in a given file, leaving >> words which have 3 or less letters. > > First or all? If first and this is the only purpose of the script you > can easily use sed: > less file.tx

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Kamil Kuduk
On Wed, Aug 22, 2012 at 12:41 PM, Chris Angelico wrote: > Why less? Why not just redirect input? Yeah, my bad, I somehow used to do it, for grep too, and I know that this is slower > Though, this isn't really on topic for Python. I would still go with regexp, something like: with open('myfile.t

Re: color coding for numbers

2012-08-22 Thread Ulrich Eckhardt
Am 21.08.2012 19:07, schrieb DJC: On 21/08/12 12:55, Ulrich Eckhardt wrote: Am 21.08.2012 10:38, schrieb namenobodywa...@gmail.com: what is the best way Define "best" before asking such questions. ;)

Re: asking

2012-08-22 Thread Tim Chase
On 08/22/12 04:42, alex23 wrote: > On 08/22/2012 03:17 AM, mingqiang hu wrote: >> I mean any of "a","b","c" in string "adfbdfc" makes the statement true,can >> I not use a function? > > any(map(string.__contains__, substrings)) As map()/reduce() vs. list-comprehension discussions are going on in

psphere: how to make thread safe

2012-08-22 Thread sajuptpm
Hi, psphere: Python interface for the VMware vSphere Web Services SDK I already developed an app using https://bitbucket.org/jkinred/psphere. But getting lot of errors since psphere is not thread safe (I think). So i wrote couple of scripts to test it (See attached files) and found that caching

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Santosh Kumar
OK! The bug one fixed. Thanks to Andreas Perstinger. Let's move to Bug #2: 2. How do I escape the words that are already in uppercase? For example: The input file has this: NASA The script changes this to: Nasa Is it possible to make this script look at a word, see if its first character is ca

Re: asking

2012-08-22 Thread Steven D'Aprano
On Wed, 22 Aug 2012 02:42:16 -0700, alex23 wrote: > On 08/22/2012 03:17 AM, mingqiang hu wrote: >> I mean any of "a","b","c" in string "adfbdfc"  makes the statement >> true,can I not use a function? > > any(map(string.__contains__, substrings)) Nice. However, be aware that in Python 2, map() i

Re: xlrd 0.8.0 released!

2012-08-22 Thread Hubert Holin
La Défense, le 22/08/2012 Hi Congratulations for the work well done, and thanks for the help xlrd brings to my work. I would like to keep up with the development but would like to know which is the repo to follow. The Python-Excel website points to https://github.com/python-excel/xlrd, but th

Re: Books?

2012-08-22 Thread Steven D'Aprano
On Tue, 21 Aug 2012 18:36:50 -0700, Anonymous Group wrote: > What books do you recomend for learning python? Preferably free and/or > online. Completely by coincidence, I have just discovered, and I mean *literally* just a few minutes ago, this book: http://www.springer.com/mathematics/computat

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Joel Goldstick
On Wed, Aug 22, 2012 at 9:00 AM, Santosh Kumar wrote: > OK! The bug one fixed. Thanks to Andreas Perstinger. > > Let's move to Bug #2: > 2. How do I escape the words that are already in uppercase? For example: > > The input file has this: > NASA > > The script changes this to: > Nasa > > Is it po

Re: Objects in Python

2012-08-22 Thread Joel Goldstick
On Wed, Aug 22, 2012 at 10:13 AM, shaun wrote: > I'm having an issue its my first time using python and i set up a class one > of the methods is supposed to return a string but instead returns: > > 389E0>> > > Im very new to python and the object orientated feature doesnt seem to be as > well p

Re: xlrd 0.8.0 released!

2012-08-22 Thread Chris Withers
On 22/08/2012 15:03, Hubert Holin wrote: I would like to keep up with the development but would like to know which is the repo to follow. The Python-Excel website points to https://github.com/python-excel/xlrd, but that one does not have a 0.8.0 tag (or at least did not have one when I looked a f

Re: Objects in Python

2012-08-22 Thread Jussi Piitulainen
shaun writes: > I'm having an issue its my first time using python and i set up a > class one of the methods is supposed to return a string but instead > returns: > > 389E0>> > > Im very new to python and the object orientated feature doesnt seem > to be as well put together as Java. Can anyone

Re: Objects in Python

2012-08-22 Thread Peter Otten
shaun wrote: > I'm having an issue its my first time using python and i set up a class > one of the methods is supposed to return a string but instead returns: > > 389E0>> > > Im very new to python and the object orientated feature doesnt seem to be > as well put together as Java. It's defini

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Rebelo
> Let's move to Bug #2: > > 2. How do I escape the words that are already in uppercase? For example: > > > > The input file has this: > > NASA > > > > The script changes this to: > > Nasa > > > > Is it possible to make this script look at a word, see if its first > > character is cap

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem? From one Java head to another I suggest you park what you know about Java and approach Python with a clear mind.

Re: Books?

2012-08-22 Thread Virgil Stokes
On 22-Aug-2012 16:04, Steven D'Aprano wrote: On Tue, 21 Aug 2012 18:36:50 -0700, Anonymous Group wrote: What books do you recomend for learning python? Preferably free and/or online. Completely by coincidence, I have just discovered, and I mean *literally* just a few minutes ago, this book: h

Re: Objects in Python

2012-08-22 Thread John Gordon
In <18409992-1e28-4721-8e64-60c69668d...@googlegroups.com> shaun writes: > I'm having an issue its my first time using python and i set up a class one > of the methods is supposed to return a string but instead returns: > 389E0>> It looks like you're referencing the method object itself, ins

Re: Objects in Python

2012-08-22 Thread shaun
Here is some code: //This is the object I want to create: #!/usr/bin/python import cx_Oracle import sys import time import datetime class batchParam: def __init__(self,array): self.array=array def breakuparray(self): for

Re: help me debug my "word capitalizer" script

2012-08-22 Thread MRAB
On 22/08/2012 09:20, Hans Mulder wrote: [snip] Alternatively, if you want to remove only the line separator, you could do: if line.endswith(linesep): line = line[:-len(linesep)] The 'if' command is only necessary for the last line, which may or may not end in a linesep.

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 1:25 AM, shaun wrote: > def breakuparray(self): > for row in self.array: > mer = row[0].ljust(25, ' ') > merc = row[1].ljust(13, ' ') > mertype = row[2] >

Re: Objects in Python

2012-08-22 Thread Dave Angel
On 08/22/2012 11:25 AM, shaun wrote: > Here is some code: > //This is the object I want to create: > #!/usr/bin/python > import cx_Oracle > import sys > import time > import datetime > > > class batchParam: > > def __init__(self,array): > self.array=arra

Re: Objects in Python

2012-08-22 Thread MRAB
On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem? From one Java head to another I suggest you park what you know about

Re: Objects in Python

2012-08-22 Thread Mark Lawrence
On 22/08/2012 16:47, Chris Angelico wrote: For what you're doing there, though, a class is overkill. Remember, Python isn't Java; the most natural way to do everything isn't necessarily to write a class that unpacks things and packs them up again in a different way. ChrisA This shows just ho

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 16:58, MRAB wrote: On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem? From one Java head to another I suggest

Re: Objects in Python

2012-08-22 Thread Mark Lawrence
On 22/08/2012 17:10, lipska the kat wrote: On 22/08/12 16:58, MRAB wrote: On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this proble

writelines puzzle

2012-08-22 Thread William R. Wing (Bill Wing)
In the middle of a longer program that reads and plots data from a log file, I have added the following five lines (rtt_data is fully qualified file name): wd = open(rtt_data, 'w') stat = wd.write(str(i)) stat = wd.writelines(str(x_dates[:i])) stat = wd.writelines(str(y_rtt[:i])) wd.close() The

Filter versus comprehension (was Re: something about split()???)

2012-08-22 Thread Terry Reedy
On 8/22/2012 3:30 AM, Mark Lawrence wrote: On 22/08/2012 06:46, Terry Reedy wrote: On 8/21/2012 11:43 PM, mingqiang hu wrote: why filter is bad when use lambda ? Inefficient, not 'bad'. Because the equivalent comprehension or generator expression does not require a function call. for each i

Re: writelines puzzle

2012-08-22 Thread Chris Kaynor
Reading your post, I do not see for sure what your actual issue is, so I am taking my best guess: that the file does not contain as much data as would be expected. On Wed, Aug 22, 2012 at 8:38 AM, William R. Wing (Bill Wing) wrote: > In the middle of a longer program that reads and plots data fro

Re: writelines puzzle

2012-08-22 Thread Joel Goldstick
On Wed, Aug 22, 2012 at 11:38 AM, William R. Wing (Bill Wing) wrote: > In the middle of a longer program that reads and plots data from a log file, > I have added the following five lines (rtt_data is fully qualified file name): > > wd = open(rtt_data, 'w') > stat = wd.write(str(i)) > stat = wd.w

Re: Objects in Python

2012-08-22 Thread Terry Reedy
On 8/22/2012 10:59 AM, lipska the kat wrote: There is no real enforced concept of information hiding, no binding of type to variable in fact no concept of typing at all as far as I can see. Given that type(valid_name) always returns a type(class), that is a slightly strange statement. What is

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 17:30, Mark Lawrence wrote: On 22/08/2012 17:10, lipska the kat wrote: On 22/08/12 16:58, MRAB wrote: On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated feature doesnt seem to be as well put together

Re: writelines puzzle

2012-08-22 Thread Jerry Hill
On Wed, Aug 22, 2012 at 11:38 AM, William R. Wing (Bill Wing) wrote: > Much to my surprise, when I looked at the output file, it only contained 160 > characters. Catting produces: > > StraylightPro:Logs wrw$ cat RTT_monitor.dat > 2354[ 734716.72185185 734716.72233796 734716.72445602 ..., 7347

Re: Objects in Python

2012-08-22 Thread Ian Kelly
In addition to the excellent feedback that Dave gave you: On Wed, Aug 22, 2012 at 9:25 AM, shaun wrote: > def breakuparray(self): > for row in self.array: > mer = row[0].ljust(25, ' ') > merc = row[1].ljust(13, ' ') >

How to properly implement worker processes

2012-08-22 Thread Dennis Jacobfeuerborn
Hi, I'm trying to implement a system for periodically checking URLs and I've run into problems with some of the implementation details. The URLs are supposed to be checked continuously until the config for an URL is explicitly removed. The plan is to spawn a worker process for each URL that send

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Terry Reedy
On 8/22/2012 10:46 AM, Rebelo wrote: Is it possible to make this script look at a word, see if its first character is capitalized, if capitalized then skip that word. Unicode has two 'capital' concepts: 'uppercase' and 'titlecase'. They are the same for latin chars but not for all alphabets.

Re: writelines puzzle

2012-08-22 Thread Peter Otten
William R. Wing (Bill Wing) wrote: > In the middle of a longer program that reads and plots data from a log > file, I have added the following five lines (rtt_data is fully qualified > file name): > > wd = open(rtt_data, 'w') > stat = wd.write(str(i)) > stat = wd.writelines(str(x_dates[:i])) > st

Re: How to properly implement worker processes

2012-08-22 Thread Ian Kelly
On Wed, Aug 22, 2012 at 11:29 AM, Dennis Jacobfeuerborn wrote: > Hi, > I'm trying to implement a system for periodically checking URLs and I've run > into problems with some of the implementation details. The URLs are supposed > to be checked continuously until the config for an URL is explicitl

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 18:01, Terry Reedy wrote: On 8/22/2012 10:59 AM, lipska the kat wrote: There is no real enforced concept of information hiding, no binding of type to variable in fact no concept of typing at all as far as I can see. Given that type(valid_name) always returns a type(class), that is

Re: Objects in Python

2012-08-22 Thread Mark Lawrence
On 22/08/2012 18:06, lipska the kat wrote: On 22/08/12 17:30, Mark Lawrence wrote: On 22/08/2012 17:10, lipska the kat wrote: On 22/08/12 16:58, MRAB wrote: On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Im very new to python and the object orientated fea

Re: Objects in Python

2012-08-22 Thread Ian Kelly
On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat wrote: > If, in a language, I find I am able to say > > a = 1 > > then later, in the same scope I can say > > a = "foo" > > then later again in the same scope I can say > > a = ([1,2,3], "xyz", True) > > then, and I may be missing something here, to

Re: PyCrypto builds neither with MSVC nor MinGW

2012-08-22 Thread bikewave
I also had the unresolved externals problem (not the mdir.h problem, though) and my solution was different. a) reinstall correct python2.6.4, using an Intel-flavor msi vice AMD64-flavor b) source the c:\program files(x86\microsoft visual studio 9.0\vc\bin\vcvars32.bat and shazzm the pycrypto bu

Re: Objects in Python

2012-08-22 Thread Mark Lawrence
On 22/08/2012 18:46, lipska the kat wrote: On 22/08/12 18:01, Terry Reedy wrote: On 8/22/2012 10:59 AM, lipska the kat wrote: There is no real enforced concept of information hiding, no binding of type to variable in fact no concept of typing at all as far as I can see. Given that type(valid

Re: PyCrypto builds neither with MSVC nor MinGW

2012-08-22 Thread Dave Angel
On 08/22/2012 02:21 PM, bikewave wrote: > I also had the unresolved externals problem (not the mdir.h problem, though) > and my solution was different. > a) reinstall correct python2.6.4, using an Intel-flavor msi vice > AMD64-flavor > b) source the c:\program files(x86\microsoft visual studio > 9.

Re: How do I display unicode value stored in a string variable using ord()

2012-08-22 Thread Hans Mulder
On 19/08/12 19:48:06, Paul Rubin wrote: > Terry Reedy writes: >> py> s = chr(0x + 1) >> py> a, b = s > That looks like a 3.2- narrow build. Such which treat unicode strings > as sequences of code units rather than sequences of codepoints. Not an > implementation bug, but compromise d

Re: writelines puzzle

2012-08-22 Thread William R. Wing (Bill Wing)
On Aug 22, 2012, at 12:48 PM, Chris Kaynor wrote: > Reading your post, I do not see for sure what your actual issue is, so > I am taking my best guess: that the file does not contain as much data > as would be expected. > Sorry, I should have been more explicit. The value of "i" in this instan

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 19:15, Ian Kelly wrote: On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat wrote: If, in a language, I find I am able to say a = 1 [snip] You're conflating "strong typing" with "static typing". Strong typing does not refer to restrictions on what type of data can be stored whe

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 08/22/2012 12:46 PM, lipska the kat wrote: > If you can show me a 'type' that cannot be assigned to > > a > > in the same scope then I would be most interested to know, I haven't > found one yet. As other people have said, you've just pointed out the difference between static typing and dynam

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 19:07, Mark Lawrence wrote: On 22/08/2012 18:06, lipska the kat wrote: On 22/08/12 17:30, Mark Lawrence wrote: On 22/08/2012 17:10, lipska the kat wrote: On 22/08/12 16:58, MRAB wrote: On 22/08/2012 15:59, lipska the kat wrote: On 22/08/12 15:13, shaun wrote: [snip] Maybe b

Re: writelines puzzle

2012-08-22 Thread Dave Angel
On 08/22/2012 02:00 PM, William R. Wing (Bill Wing) wrote: > On Aug 22, 2012, at 12:48 PM, Chris Kaynor wrote: > >> Reading your post, I do not see for sure what your actual issue is, so >> I am taking my best guess: that the file does not contain as much data >> as would be expected. >> > Sorry,

Re: writelines puzzle

2012-08-22 Thread William R. Wing (Bill Wing)
On Aug 22, 2012, at 1:28 PM, Jerry Hill wrote: > On Wed, Aug 22, 2012 at 11:38 AM, William R. Wing (Bill Wing) > wrote: >> Much to my surprise, when I looked at the output file, it only contained 160 >> characters. Catting produces: >> >> StraylightPro:Logs wrw$ cat RTT_monitor.dat >> 2354[ 7

Re: How to properly implement worker processes

2012-08-22 Thread Dennis Jacobfeuerborn
On Wednesday, August 22, 2012 7:46:34 PM UTC+2, Ian wrote: > On Wed, Aug 22, 2012 at 11:29 AM, Dennis Jacobfeuerborn > > wrote: > > > Hi, > > > I'm trying to implement a system for periodically checking URLs and I've > > run into problems with some of the implementation details. The URLs are

Re: Objects in Python

2012-08-22 Thread lipska the kat
On 22/08/12 20:03, Evan Driscoll wrote: On 08/22/2012 12:46 PM, lipska the kat wrote: If you can show me a 'type' that cannot be assigned to a in the same scope then I would be most interested to know, I haven't found one yet. [snip] Second, this concept isn't *so* unfamiliar to you. If

Re: Objects in Python

2012-08-22 Thread MRAB
On 22/08/2012 20:45, lipska the kat wrote: On 22/08/12 20:03, Evan Driscoll wrote: On 08/22/2012 12:46 PM, lipska the kat wrote: If you can show me a 'type' that cannot be assigned to a in the same scope then I would be most interested to know, I haven't found one yet. [snip] Second, th

Re: Objects in Python

2012-08-22 Thread Mark Lawrence
On 22/08/2012 21:31, MRAB wrote: On 22/08/2012 20:45, lipska the kat wrote: compare this to a function declaration in Python def foo(self): [snip] That's not actually a declaration but a definition. :-) The function's body is bound to the name at runtime, so: def double_it(x):

Re: How to properly implement worker processes

2012-08-22 Thread Ian Kelly
On Wed, Aug 22, 2012 at 1:40 PM, Dennis Jacobfeuerborn wrote: > I was thinking about something like that but the issue is that this really > only works when you don't do any actual blocking work. I may be able to get > around the sleep() but then I have to fetch the URL or do some other work >

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 08/22/2012 02:45 PM, lipska the kat wrote: > On 22/08/12 20:03, Evan Driscoll wrote: >> Second, this concept isn't *so* unfamiliar to you. If I give you the >> following Java code: >> >>void foo(Object o) { ... } >> > looking at this method declaration I can see that the method takes an > ar

Re: Objects in Python

2012-08-22 Thread Ben Finney
lipska the kat writes: > If, in a language, I find I am able to say > > a = 1 > > then later, in the same scope I can say > > a = "foo" > > then later again in the same scope I can say > > a = ([1,2,3], "xyz", True) > > then, and I may be missing something here, to me, that doesn't say > strongly

Re: Objects in Python

2012-08-22 Thread Ian Kelly
On Wed, Aug 22, 2012 at 5:58 PM, Ben Finney wrote: > Those people are confused, then. Python is strongly typed: objects > always know their type, the type is always exact, and the type of an > object can't be changed. Except when it can. >>> class A: pass ... >>> class B: pass ... >>> a = A() >>

Re: Objects in Python

2012-08-22 Thread Walter Hurry
On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote: > Well I'm a beginner Then maybe you should read more and write less. -- http://mail.python.org/mailman/listinfo/python-list

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 5:03 AM, lipska the kat wrote: > On 22/08/12 19:15, Ian Kelly wrote: >> >> You're conflating "strong typing" with "static typing". Strong typing >> does not refer to restrictions on what type of data can be stored >> where, but to restrictions on how operations on that dat

Re: How to properly implement worker processes

2012-08-22 Thread Dennis Jacobfeuerborn
On Wednesday, August 22, 2012 11:15:10 PM UTC+2, Ian wrote: > On Wed, Aug 22, 2012 at 1:40 PM, Dennis Jacobfeuerborn > > wrote: > > > I was thinking about something like that but the issue is that this really > > only works when you don't do any actual blocking work. I may be able to get > > a

Methods versus functions [was Re: Objects in Python]

2012-08-22 Thread Steven D'Aprano
On Wed, 22 Aug 2012 21:46:29 +0100, Mark Lawrence wrote: >> On 22/08/2012 20:45, lipska the kat wrote: >>> >>> compare this to a function declaration in Python >>> >>> def foo(self): [...] > Looking at the self I'm assuming that's a method and not a function. Actually, it is a function. It doesn

Re: Objects in Python

2012-08-22 Thread Steven D'Aprano
On Thu, 23 Aug 2012 12:02:16 +1000, Chris Angelico wrote: > 2) Related to the above, you can infinitely nest scopes. There's nothing > wrong with having six variables called 'q'; you always use the innermost > one. Yes, this can hurt readability Well, there you go. There *is* something wrong with

Re: Objects in Python

2012-08-22 Thread Steven D'Aprano
On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote: > We need to separate out the 'view' from the 'implementation' here. Most > developers I know, if looking at the code and without the possibly > dubious benefit of knowing that in Python 'everything is an object' > would not call this 'stro

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
On 8/22/2012 18:58, Ben Finney wrote: > You haven't discovered anything about types; what you have discovered is > that Python name bindings are not variables. > > In fact, Python doesn't have variables – not as C or Java programmers > would understand the term. What it has instead are references

Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:11 PM, Steven D'Aprano wrote: > On Thu, 23 Aug 2012 12:02:16 +1000, Chris Angelico wrote: > >> 2) Related to the above, you can infinitely nest scopes. There's nothing >> wrong with having six variables called 'q'; you always use the innermost >> one. Yes, this can hurt r

Re: Re: Objects in Python

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:49 PM, Evan Driscoll wrote: > On 8/22/2012 18:58, Ben Finney wrote: >> You haven't discovered anything about types; what you have discovered is >> that Python name bindings are not variables. >> >> In fact, Python doesn't have variables – not as C or Java programmers >> w