Re: Can't understand what python wants from me

2009-01-29 Thread mark . seagoe
On Jan 29, 1:50 pm, Oleksiy Khilkevich wrote: > Hello, everyone, > This may be a totally noob question, but since I am one, so here is it. For the input function, python is expecting you to input a number or a string. If you enter 'asd' without the '' then it thinks you are entering some variabl

Re: parsing text from a file

2009-01-29 Thread John Machin
On Jan 30, 8:54 am, Wes James wrote: > If I read a windows registry file with a line like this: > > "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program > Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted > Multicast|Edge

Re: parsing text from a file

2009-01-29 Thread Tim Chase
if s.find('LANDesk') <0: is True for a line which doesn't contain "LANDesk"; if you want the opposite, try if s.find('LANDesk') >-1: Or more pythonically, just use if 'LANDesk' in s: -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Stef Mientki
[email protected] wrote: I'm trying to make a script environment with datatypes (or classes) for accessing hardware registers. At the top level, I would like the ability to bitwise ops if bit slice brackets are used, but if no brackets are used, I would like it to write/read the whole value.

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread John Machin
On Jan 30, 9:02 am, [email protected] wrote: > I'm trying to make a script environment with datatypes (or classes) > for accessing hardware registers.  At the top level, I would like the > ability to bitwise ops if bit slice brackets are used, but if no > brackets are used, I would like it to w

Re: receive and react to MIDI input

2009-01-29 Thread elsjaako
On Jan 29, 8:33 pm, elsjaako wrote: > I think this means that the following could be said: > > typedef void *HANDLE; > struct HMIDIIN##__ { int unused; }; typedef struct HMIDIIN##__ > *HMIDIIN; > I figured this problem out (I'm sure there will be more...): A handle should just be a c_void_p ... -

Re: Sloooooowwwww WSGI restart

2009-01-29 Thread Ron Garret
In article <[email protected]>, Bruno Desthuilliers wrote: > Ron Garret a écrit : > > In article , > > Aleksandar Radulovic wrote: > (snip) > >> Secondly, why are you restarting apache after code changes? In normal > >> circumstances, you shouldn't have to do that. > > >

Re: Sloooooowwwww WSGI restart

2009-01-29 Thread Ron Garret
In article <[email protected]>, Bruno Desthuilliers wrote: > Ron Garret a écrit : > > I'm running a WSGI app under apache/mod_wsgi and I've noticed that > > whenever I restart the server after making a code change it takes a very > > long time (like a minute) before the

More mod_wsgi weirdness: process restarts on redirect

2009-01-29 Thread Ron Garret
I'm running mod_wsgi under apache (on Debian etch so it's a somewhat out of date version, though I doubt that has anything to do with this issue). I have a little test page that displays the process ID under which my app is running, and some global state, so I can tell when the wsgi app gets re

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread John Machin
On Jan 30, 9:55 am, Stef Mientki wrote: >   def __repr__ ( self ) : >     line = hex ( self.Value ) >     line = line [:2] + line [2:].upper() >     return line > > btw, I'm a hardware guy too, and therefor I've never understood why the > hex function returns lowercase ;-) 0xFF?? *Real* hardware

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
Thanks. So far these solutions will return strings. So I can't really treat it like a variable, yet still perform bitslice on it, since I need a special class to do bitslice and bit selection, but as soon as I try to pass it into some other function to check a bit, I gotta then do another operati

Re: py2exe + SQLite problem

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 13:05:11 -0200, Armin escribió: I have frozen a running application which is using SQLite with py2exe. When I start the exe file I see in the log file of the exe: Traceback (most recent call last): File "dpconf.py", line 666, in ? File "dpconf.py", line 251, in __init_

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Stef Mientki
[email protected] wrote: Thanks. So far these solutions will return strings. So I can't really treat it like a variable, yet still perform bitslice on it, since I need a special class to do bitslice and bit selection, but as soon as I try to pass it into some other function to check a bit,

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Stef Mientki
[email protected] wrote: Thanks. So far these solutions will return strings. So I can't really treat it like a variable, yet still perform bitslice on it, since I need a special class to do bitslice and bit selection, but as soon as I try to pass it into some other function to check a bit,

Re: receive and react to MIDI input

2009-01-29 Thread elsjaako
On Jan 29, 10:44 pm, elsjaako wrote: > On Jan 29, 9:36 pm, r wrote: > > > On Jan 29, 1:33 pm, elsjaako wrote: > > > There is a Python MIDI module, i think it is pyMIDI, have you checked > > it out? > > Thank you for the responce. Unfortunately, that package is for OS X > (it doesn't say that cle

Re: Exec woes

2009-01-29 Thread Rhodri James
On Thu, 29 Jan 2009 08:15:57 -, Hendrik van Rooyen wrote: "Rhodri James" wrote: To: Sent: Thursday, January 29, 2009 6:12 AM Subject: Re: Exec woes On Wed, 28 Jan 2009 07:47:00 -, Hendrik van Rooyen wrote: > This is actually not correct - it is the root cause of my trouble.

Re: More mod_wsgi weirdness: process restarts on redirect

2009-01-29 Thread Joshua Kugler
Ron Garret wrote: > My question is: is this supposed to be happening? Or is this an > indication that something is wrong, and if so, what? You are probably just hitting a different instance of Apache, thus the different process ID. j -- http://mail.python.org/mailman/listinfo/python-list

Understanding descriptors

2009-01-29 Thread Brian Allen Vanderburg II
I'm trying to better understand descriptors and I've got a few questions still after reading some sites. Here is what I 'think', but please let me know if any of this is wrong as I'm sure it probably is. First when accessing an attribute on a class or instance it must be found. For an insta

Re: More mod_wsgi weirdness: process restarts on redirect

2009-01-29 Thread Ron Garret
In article , Ron Garret wrote: > I'm running mod_wsgi under apache (on Debian etch so it's a somewhat out > of date version, though I doubt that has anything to do with this issue). > > I have a little test page that displays the process ID under which my > app is running, and some global sta

Re: Get thread pid

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 14:04:49 -0200, Alejandro escribió: I have Python program running under Linux, that create several threads, and I want to now the corresponding PID of the threads. In each of the threads I have def run(self): pid = os.getpid() logger.critical('process ID: %s', pi

Re: receive and react to MIDI input

2009-01-29 Thread elsjaako
On Jan 30, 12:26 am, elsjaako wrote: > On Jan 29, 10:44 pm, elsjaako wrote: > > > On Jan 29, 9:36 pm, r wrote: > > > > On Jan 29, 1:33 pm, elsjaako wrote: > > > > There is a Python MIDI module, i think it is pyMIDI, have you checked > > > it out? > > > Thank you for the responce. Unfortunately,

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
On Jan 29, 3:13 pm, Stef Mientki wrote: > [email protected] wrote: > > Thanks.  So far these solutions will return strings.  So I can't > > really treat it like a variable, yet still perform bitslice on it, > > since I need a special class to do bitslice and bit selection, but as > > soon as I

Re: parsing text from a file

2009-01-29 Thread MRAB
Wes James wrote: If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" with this code: f

Re: Weird invisible arguments issues with Windows

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 19:31:08 -0200, Uberman escribió: You all seem to be pointing at the same thing, and on my system, I show: C:\Users\Administrator>ftype python.file python.file="D:\Python26\python.exe" "%1" %* and C:\Users\Administrator>assoc .py .py=Python.File Which all

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread MRAB
John Machin wrote: On Jan 30, 9:02 am, [email protected] wrote: I'm trying to make a script environment with datatypes (or classes) for accessing hardware registers. At the top level, I would like the ability to bitwise ops if bit slice brackets are used, but if no brackets are used, I woul

Re: More mod_wsgi weirdness: process restarts on redirect

2009-01-29 Thread Ron Garret
In article , Joshua Kugler wrote: > Ron Garret wrote: > > My question is: is this supposed to be happening? Or is this an > > indication that something is wrong, and if so, what? > > You are probably just hitting a different instance of Apache, thus the > different process ID. Yep, that's wha

Rounding to the nearest 5

2009-01-29 Thread [email protected]
How can you make python round numbers to the nearest 5: Example: 3 => 0 8 => 10 23.2 => 20 36 => 35 51.5 => 50 Thanks! _ Twice the fun—Share photos while you chat with Windows Live Messenger. http://www.microsoft.com/windows/w

Re: slicings: 3 questions

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 19:41:28 -0200, Robert Kern escribió: On 2009-01-29 15:33, Alan G Isaac wrote: On 1/29/2009 1:37 PM Chris Rebert apparently wrote: Also, more fundamentally, Python is liberal in what it allows for the parts of slices, so unifying slices with ranges would break code. For

error on building 2.6.1. (_ctypes)

2009-01-29 Thread Bernard Rankin
Hello, I am trying to build python 2.6 on a machine (web server) that I do not have root access to. (has 2.4 installed) Python 2.5 builds fine, but I am getting an error when I run "make" for 2.6.1. Here is the command line I am using: ../configure -prefix=/home/username/local-python/ --enable

Re: ImportError in embedded Python Interpreter

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 17:07:01 -0200, escribió: i have a problem. I compiled Python and the socket module so I got this structure. (all on windows) C:\test\dll_files\python25.dll C:\test\my_app C:\test\dll_files\DLLs\ C:\test\dll_files\python.exe If I run python.exe I get the console and I ca

Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread r
I been around the list for a while and rubbed sholders with some pythonistas(some you would not beleieve if i told you) and i just don't see a community spirit here. Where are the community projects supporting Python? -- besides the core devlopment. Seem s that nobody is interested unless their pa

Re: self-aware list of objects able to sense constituent member alterations?

2009-01-29 Thread Reckoner
On Jan 28, 10:17 pm, Peter Wang wrote: > On Jan 27, 3:16 pm,Reckoner wrote: > > > > > I'm not sure this is possible, but I would like to have > > a list of  objects > > > A=[a,b,c,d,...,z] > > > where,  in the midst of a lot of processing I might do something like, > > > A[0].do_something_which_c

Re: Rounding to the nearest 5

2009-01-29 Thread Tim Chase
How can you make python round numbers to the nearest 5: Example: 3 => 0 8 => 10 23.2 => 20 36 => 35 51.5 => 50 I'm not sure *any* rounding system will give those results. 3 should round up to 5 (not down to 0) and 23.2 should round up to 25 (not down to 20) in the same way that 8 rounds

Re: Rounding to the nearest 5

2009-01-29 Thread MRAB
[email protected] wrote: How can you make python round numbers to the nearest 5: Example: 3 => 0 8 => 10 23.2 => 20 36 => 35 51.5 => 50 Divide by 5, round the result, then multiply by 5. -- http://mail.python.org/mailman/listinfo/python-list

Re: Quickbooks

2009-01-29 Thread viglen
On Jan 28, 1:21 pm, Stephen Chapman wrote: > Has anyone Implemented the Quickbooks  COM object in Python.  If so can > you give me > an Idea of where to begin. > Thanks Have you tried to contact the customer support team? I have used them many times and they are very helpful. They have different

Re: slicings: 3 questions

2009-01-29 Thread Alan G Isaac
On 1/29/2009 4:41 PM Robert Kern apparently wrote: It allows (ab)uses like numpy.mgrid: >>> mgrid[0:10:11j] array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]) Ah of course. Obvious now, but I had presumed some deeper magic in that syntax, not recognizing that a legitim

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Jervis Whitley
On Fri, Jan 30, 2009 at 9:02 AM, wrote: > I'm trying to make a script environment with datatypes (or classes) > for accessing hardware registers. At the top level, I would like the > ability to bitwise ops if bit slice brackets are used, but if no > brackets are used, I would like it to write/re

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
On Jan 29, 3:13 pm, Stef Mientki wrote: > [email protected] wrote: > > Thanks.  So far these solutions will return strings.  So I can't > > really treat it like a variable, yet still perform bitslice on it, > > since I need a special class to do bitslice and bit selection, but as > > soon as I

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Marc 'BlackJack' Rintsch
On Fri, 30 Jan 2009 00:25:03 +0100, Stef Mientki wrote: > try this: > > class MyRegClass ( int ) : > def __init__ ( self, value ) : > self.Value = value > def __repr__ ( self ) : > line = hex ( self.Value ) > line = line [:2] + line [2:].upper() > return line def __repr__

naming and binding (subtle Python 3 change)

2009-01-29 Thread Alan G Isaac
The example give at http://docs.python.org/reference/executionmodel.html#naming-and-binding remains unchanged at http://docs.python.org/3.0/reference/executionmodel.html#naming-and-binding but the change to Python 3 list comprehensions now means the example will fail even with list comprehension s

Swapping values of two variables

2009-01-29 Thread Eric Kang
In python, I set: x=1 y=3 z = x x = y y = z This gave me 3 1, which are the values of x and y swapped. The following would have given me the same result: x, y = y, x But could the swapping be done using less extra memory than this? What is the minimum amount of extra memory required to exch

Re: Swapping values of two variables

2009-01-29 Thread MRAB
Eric Kang wrote: In python, I set: x=1 y=3 z = x x = y y = z This gave me 3 1, which are the values of x and y swapped. The following would have given me the same result: x, y = y, x But could the swapping be done using less extra memory than this? What is the minimum amount of extra memory

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread Giampaolo Rodola'
> Where are the community projects supporting Python? -- besides the > core devlopment. http://pypi.python.org/pypi ...which accidentally says "There are currently 5597 packages here." Not bad uh? --- Giampaolo http://code.google.com/p/pyftpdlib -- http://mail.python.org/mailman/listinfo/pytho

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2009-01-29 Thread John Machin
Benjamin Kaplan case.edu> writes: > First of all, you're right that might be confusing. I was thinking of auto-detect as in "check the platform and locale and guess what they usually use". I wasn't thinking of it like the web browsers use it.I think it uses locale.getpreferredencoding(). You're

Re: More mod_wsgi weirdness: process restarts on redirect

2009-01-29 Thread Graham Dumpleton
On Jan 30, 11:01 am, Ron Garret wrote: > In article , >  Joshua Kugler wrote: > > > Ron Garret wrote: > > > My question is: is this supposed to be happening?  Or is this an > > > indication that something is wrong, and if so, what? > > > You are probably just hitting a different instance of Apach

Re: Sloooooowwwww WSGI restart

2009-01-29 Thread Graham Dumpleton
On Jan 30, 9:53 am, Ron Garret wrote: > In article <[email protected]>, >  Bruno Desthuilliers > >  wrote: > > Ron Garret a écrit : > > > In article , > > >  Aleksandar Radulovic wrote: > > (snip) > > >> Secondly, why are you restarting apache after code changes? In normal >

Re: Swapping values of two variables

2009-01-29 Thread tony . clarke5
On Jan 30, 12:29 am, Eric Kang wrote: > In python, I set: > > x=1 > y=3 > > z = x > x = y > y = z > > This gave me 3 1, which are the values of x and y swapped. > The following would have given me the same result: > x, y = y, x > > But could the swapping be done using less extra memory than this?

new.instancemethod questions

2009-01-29 Thread schickb
I'd like to add bound functions to instances, and found the instancemethod function in the new module. A few questions: 1. Why is instancemethod even needed? Its counter-intuitive (to me at least) that assigning a function to a class results in bound functions its instances, while assigning direct

Using equals operator without changing reference pointer

2009-01-29 Thread mark . seagoe
I know this may be asking too much of Python, but you never know unless you ask... So now having a class that can be treated like an int as far as math upon the instance name, and can be treated as in HDL simulators, allowing bitslice and bitselect ops, I was stoked. Also reading back the instanc

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread alex23
On Jan 30, 10:21 am, r wrote: > I been around the list for a while and rubbed sholders with some > pythonistas(some you would not beleieve if i told you) and i just > don't see a community spirit here. Seriously, how -old- are you? Twelve? Thirteen? -- http://mail.python.org/mailman/listinfo/pyth

Re: Using equals operator without changing reference pointer

2009-01-29 Thread Erik Max Francis
[email protected] wrote: Is there a way to lock down myInst so that it still refers to the original object, and is there some special member that will allow me to override the equals operator in this case? Or is that simply blasphemous against everything Python holds sacred? Certainly ther

Re: Swapping values of two variables

2009-01-29 Thread Steven D'Aprano
On Thu, 29 Jan 2009 16:29:11 -0800, Eric Kang wrote: > In python, I set: > > x=1 > y=3 > > z = x > x = y > y = z > > > This gave me 3 1, which are the values of x and y swapped. The following > would have given me the same result: x, y = y, x Yes. > But could the swapping be done using less

Re: Swapping values of two variables

2009-01-29 Thread Steven D'Aprano
On Thu, 29 Jan 2009 17:50:04 -0800, tony.clarke5 wrote: > On Jan 30, 12:29 am, Eric Kang wrote: >> In python, I set: >> >> x=1 >> y=3 >> >> z = x >> x = y >> y = z >> >> This gave me 3 1, which are the values of x and y swapped. The >> following would have given me the same result: x, y = y, x >>

Re: is python Object oriented??

2009-01-29 Thread Steven D'Aprano
On Thu, 29 Jan 2009 02:25:57 -0800, Chris Rebert wrote: > In addition to methods, Python has functions, which are not associated > with a class Yes they are. >>> (lambda: None).__class__ The function type itself has a class: >>> (lambda: None).__class__.__class__ -- Steven -- http://mail

Re: new.instancemethod questions

2009-01-29 Thread Mel
schickb wrote: > I'd like to add bound functions to instances, and found the > instancemethod function in the new module. A few questions: > > 1. Why is instancemethod even needed? Its counter-intuitive (to me at > least) that assigning a function to a class results in bound functions > its insta

Re: naming and binding (subtle Python 3 change)

2009-01-29 Thread Terry Reedy
Alan G Isaac wrote: The example give at http://docs.python.org/reference/executionmodel.html#naming-and-binding remains unchanged at http://docs.python.org/3.0/reference/executionmodel.html#naming-and-binding but the change to Python 3 list comprehensions now means the example will fail even with

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 7:31 PM, Steven D'Aprano wrote: > On Thu, 29 Jan 2009 02:25:57 -0800, Chris Rebert wrote: > >> In addition to methods, Python has functions, which are not associated >> with a class > > Yes they are. > (lambda: None).__class__ > > > The function type itself has a clas

Re: Rounding to the nearest 5

2009-01-29 Thread Steven D'Aprano
On Thu, 29 Jan 2009 18:26:34 -0600, Tim Chase wrote: >> How can you make python round numbers to the nearest 5: >> >> Example: >> >> 3 => 0 >> 8 => 10 >> 23.2 => 20 >> 36 => 35 >> 51.5 => 50 > > I'm not sure *any* rounding system will give those results. Round towards zero. > 3 should roun

Re: new.instancemethod questions

2009-01-29 Thread schickb
On Jan 29, 7:38 pm, Mel wrote: > schickb wrote: > > I'd like to add bound functions to instances, and found the > > instancemethod function in the new module. A few questions: > > > 1. Why is instancemethod even needed? Its counter-intuitive (to me at > > least) that assigning a function to a clas

Re: Using equals operator without changing reference pointer

2009-01-29 Thread Terry Reedy
Erik Max Francis wrote: [email protected] wrote: Is there a way to lock down myInst so that it still refers to the original object, and is there some special member that will allow me to override the equals operator in this case? Or is that simply blasphemous against everything Python hold

Module/Library That is Able To Use Cookies + Proxies?

2009-01-29 Thread blackcapsoftware
Hey guys, I have been search the net for a bit now and can't find anything. What I would like to do is be able to log into a site that uses cookies to store information about the user when logging in. This works fine and dandy with ClientCookie. Now, I want to be able to do so with a proxy, does a

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread Ben Finney
alex23 writes: > On Jan 30, 10:21 am, r wrote: > > I been around the list for a while and rubbed sholders with some > > pythonistas(some you would not beleieve if i told you) and i just > > don't see a community spirit here. > > Seriously, how -old- are you? Twelve? Thirteen? Please stop baiti

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread r
On Jan 29, 9:01 pm, alex23 wrote: > Seriously, how -old- are you? Twelve? Thirteen? Ah, my good friend alex23. Somehow -- when i was writing this post -- i knew you would drop in and i swear i do not have any ESP abilities -- somehow i just knew. While your here why don't we take a walk down mem

Re: error on building 2.6.1. (_ctypes)

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 22:19:18 -0200, Bernard Rankin escribió: I am trying to build python 2.6 on a machine (web server) that I do not have root access to. (has 2.4 installed) Python 2.5 builds fine, but I am getting an error when I run "make" for 2.6.1. ~

libsudo ?

2009-01-29 Thread Linuxguy123
Does anyone know where I would find libsudo ? If you had the choice of using pexpect or libsudo, which would you use ? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: search speed

2009-01-29 Thread r
On Jan 29, 5:51 pm, anders wrote: > if file.findInFile("LF01"): > Is there any library like this ?? > Best Regards > Anders Yea, it's called a for loop! for line in file: if "string" in line: do_this() -- http://mail.python.org/mailman/listinfo/python-list

Re: new.instancemethod questions

2009-01-29 Thread Brian Allen Vanderburg II
[email protected] wrote: On Jan 29, 7:38 pm, Mel wrote: schickb wrote: I'd like to add bound functions to instances, and found the instancemethod function in the new module. A few questions: 1. Why is instancemethod even needed? Its counter-intuitive (to me at least) that assig

Re: libsudo ?

2009-01-29 Thread Brian Allen Vanderburg II
[email protected] wrote: Does anyone know where I would find libsudo ? http://sourceforge.net/projects/libsudo If you had the choice of using pexpect or libsudo, which would you use ? libsudo does all the work for you of executing sudo, checking for the expected responses and all. I

Re: Rounding to the nearest 5

2009-01-29 Thread D'Arcy J.M. Cain
On Thu, 29 Jan 2009 16:06:09 -0800 "[email protected]" wrote: > How can you make python round numbers to the nearest 5: > > Example: > > 3 => 0 > 8 => 10 > 23.2 => 20 > 36 => 35 > 51.5 => 50 That appears to be rounding to nearest 10, not 5. Clarify your requirements first. -- D'Arcy J.M.

Re: Swapping values of two variables

2009-01-29 Thread Kottiyath
On Jan 30, 8:31 am, Steven D'Aprano wrote: > On Thu, 29 Jan 2009 17:50:04 -0800, tony.clarke5 wrote: > > On Jan 30, 12:29 am, Eric Kang wrote: > >> In python, I set: > > >> x=1 > >> y=3 > > >> z = x > >> x = y > >> y = z > > >> This gave me 3 1, which are the values of x and y swapped. The > >> f

Re: Swapping values of two variables

2009-01-29 Thread Grant Edwards
On 2009-01-30, MRAB wrote: >> What is the minimum amount of extra memory required to exchange two >> 32-bit quantities? What would be the pseudocode that achieves this >> minimum? > > x ^= y > y ^= x > x ^= y > > This is really only of use when working in assembly language. And rarely then. ;)

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread r
On Jan 29, 6:21 pm, r wrote: > Also if anyone dares to mention that Python is a great language or > better in this reguard or that, they get jumped and beat to death by > their "so-called" brothers. This observation leads me to two scientific and common sense synopsis. Either nobody here gives a

Re: search speed

2009-01-29 Thread alex23
On Jan 30, 2:56 pm, r wrote: > On Jan 29, 5:51 pm, anders wrote: > > > if file.findInFile("LF01"): > > Is there any library like this ?? > > Best Regards > > Anders > > Yea, it's called a for loop! > > for line in file: >     if "string" in line: >         do_this() Which is what the OP is alrea

Re: Rounding to the nearest 5

2009-01-29 Thread Miles
On Thu, Jan 29, 2009 at 7:26 PM, Tim Chase wrote: >> How can you make python round numbers to the nearest 5: >> Example: >> 3 => 0 >> 8 => 10 >> 23.2 => 20 >> 36 => 35 >> 51.5 => 50 > > I'm not sure *any* rounding system will give those results. def bogoround(n): n1 = n / 5.0 return int(

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread James Mills
On Fri, Jan 30, 2009 at 3:38 PM, r wrote: > This observation leads me to two scientific and common sense synopsis. > Either nobody here gives a rats pa'toote about Python, and/or they are > all just a bunch of gutless worms too afraid to stand up to the 10 or > so Perl/Ruby leeches who's infestati

Re: Module/Library That is Able To Use Cookies + Proxies?

2009-01-29 Thread Justin Ezequiel
On Jan 30, 12:06 pm, [email protected] wrote: > I would like to do is be able to log into a site that uses cookies to > store information about the user when logging in. This works fine and > dandy with ClientCookie. Now, I want to be able to do so with a proxy, urllib2 http://docs.pytho

Re: is python Object oriented??

2009-01-29 Thread Hung Vo
On Jan 30, 4:19 am, Michael Torrie wrote: > M Kumar wrote: > > but still I am not clear of the execution of the code, when we write or > > execute a piece of python code without defining class, predefined class > > attributes are available (not all but __name__ and __doc__ are available). > > does

Re: is python Object oriented??

2009-01-29 Thread Hung Vo
On Jan 30, 4:19 am, Michael Torrie wrote: > M Kumar wrote: > > but still I am not clear of the execution of the code, when we write or > > execute a piece of python code without defining class, predefined class > > attributes are available (not all but __name__ and __doc__ are available). > > does

Re: is python Object oriented??

2009-01-29 Thread Hung Vo
On Jan 30, 4:19 am, Michael Torrie wrote: > M Kumar wrote: > > but still I am not clear of the execution of the code, when we write or > > execute a piece of python code without defining class, predefined class > > attributes are available (not all but __name__ and __doc__ are available). > > does

Re: is python Object oriented??

2009-01-29 Thread alex23
On Jan 30, 4:00 pm, Hung Vo wrote: > Does Python follow the concepts/practices of Encapsulation, > Polymorphism and Interface, which are quite familiar to Java > programmers? Well, it has the same _concepts_, but definitely not the same practices/implementations. As they say, Python is not Java

Re: is python Object oriented??

2009-01-29 Thread Stephen Hansen
> I'm new to Python and also wondering about OOP in Python. > > I want to justify the above question (is Python Object-Oriented?). > Does Python follow the concepts/practices of Encapsulation, > Polymorphism and Interface, which are quite familiar to Java > programmers? Python does not enforce En

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 9:56 PM, Hung Vo wrote: > I'm new to Python and also wondering about OOP in Python. > > I want to justify the above question (is Python Object-Oriented?). > Does Python follow the concepts/practices of Encapsulation, > Polymorphism and Interface, which are quite familiar t

Re: new.instancemethod questions

2009-01-29 Thread schickb
On Jan 29, 8:51 pm, Brian Allen Vanderburg II wrote: > You can also create a bound method and manually bind it to the > instance.  This is easier > > import types > a.f2 = types.MethodType(f1, a) > > a.f2() # prints object a Ah thanks, that is what I was looking for. I missed that because followi

Re: Rounding to the nearest 5

2009-01-29 Thread Steven D'Aprano
On Fri, 30 Jan 2009 00:24:47 -0500, D'Arcy J.M. Cain wrote: > On Thu, 29 Jan 2009 16:06:09 -0800 > "[email protected]" wrote: >> How can you make python round numbers to the nearest 5: >> >> Example: >> >> 3 => 0 >> 8 => 10 >> 23.2 => 20 >> 36 => 35 >> 51.5 => 50 > > That appears to be rou

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread r
On Jan 29, 11:53 pm, James Mills wrote: > On Fri, Jan 30, 2009 at 3:38 PM, r wrote: > > This observation leads me to two scientific and common sense synopsis. > > Either nobody here gives a rats pa'toote about Python, and/or they are > > all just a bunch of gutless worms too afraid to stand up to

Re: is python Object oriented??

2009-01-29 Thread alex23
On Jan 30, 4:15 pm, Chris Rebert wrote: > - Python does not support interfaces in the Java sense (although there > are a few third-party libraries that add such support); neither does > Smalltalk. Instead, both Smalltalk and Python use duck-typing to > similar effect. Seehttp://en.wikipedia.org/wi

Re: Swapping values of two variables

2009-01-29 Thread tony . clarke5
On Jan 30, 3:31 am, Steven D'Aprano wrote: > On Thu, 29 Jan 2009 17:50:04 -0800, tony.clarke5 wrote: > > On Jan 30, 12:29 am, Eric Kang wrote: > >> In python, I set: > > >> x=1 > >> y=3 > > >> z = x > >> x = y > >> y = z > > >> This gave me 3 1, which are the values of x and y swapped. The > >> f

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 10:25 PM, alex23 wrote: > On Jan 30, 4:15 pm, Chris Rebert wrote: >> - Python does not support interfaces in the Java sense (although there >> are a few third-party libraries that add such support); neither does >> Smalltalk. Instead, both Smalltalk and Python use duck-typ

Re: Swapping values of two variables

2009-01-29 Thread Steven D'Aprano
On Thu, 29 Jan 2009 21:23:48 -0800, Kottiyath wrote: > Is it possible to swap two floats without a variable? In Python? Sure. f = 1.23 g = 2.87 f, g = g, f This idiom is independent of the types of the objects: x = "hello world" y = [1, 2.0, None, "xyz", {}] x, y = y, x In other languages?

'Address already in use' ... with TCPServer

2009-01-29 Thread Mabooka-Mabooka Mbe-Mbe
Hi all, I bet everybody knows exactly what I am about to ask about: ''' A server serves for a while, then drops on its knees, tries to restart, but... the port is busy, the TCP says "Address already in use". ''' And, I think I know the answer: setsockopt(REUSEADDR)... The problem is: I a

<    1   2