Re: Is this a bug in Python or something I do not understand.

2009-01-01 Thread Chris Rebert
On Thu, Jan 1, 2009 at 10:13 AM, davida...@gmail.com wrote: Consider these two lists comprehensions: L1=[[1 for j in range(3)] for i in range(3)] L2=[[1]*3]*3 snip So far, everything is OK, but let us now modify the lists' contents in the following way: snip It seems a misbehaviour in

Re: ResponseNotReady exception

2009-01-03 Thread Chris Rebert
On Sat, Jan 3, 2009 at 12:38 PM, asit lipu...@gmail.com wrote: import httplib class Server: #server class def __init__(self, host): self.host = host def fetch(self, path): http = httplib.HTTPConnection(self.host) http.putrequest(GET, path) According to the

Re: [email/quoprimime.py] AttributeError: 'tuple' object has no attribute 'lstrip'

2009-01-04 Thread Chris Rebert
On Sun, Jan 4, 2009 at 11:15 PM, Gilles Ganault nos...@nospam.com wrote: Hello I successfully use the email package to send e-mail from Python scripts, but this script fails when I fetch addresses from an SQLite database where data is Unicode-encoded: == from email.MIMEText

Re: Python callback functions and static methods

2009-01-05 Thread Chris Rebert
On Mon, Jan 5, 2009 at 9:00 AM, Joris djm...@gmail.com wrote: Hello, I'm trying to implement callback functionality in a static class. I have a feeling that I'm doing something against the Python philosophy and not some programming error but any help would be appreciated. First, a piece of

Re: __builtin__ quote

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 12:47 AM, Steven Woody narkewo...@gmail.com wrote: On Tue, Jan 6, 2009 at 4:42 PM, James Stroud jstr...@mbi.ucla.edu wrote: Steven Woody wrote: Hi, I am a new leaner and I get a question: abs() is a member of __builtin__ module, but why should I use abs() rather than

Re: __builtin__ quote

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 12:38 AM, Steven Woody narkewo...@gmail.com wrote: Hi, I am a new leaner and I get a question: abs() is a member of __builtin__ module, but why should I use abs() rather than __builtin__.abs() ? Thanks. To clarify, having __builtin__ is just the language's way of

Re: subclassing 'list'

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 12:34 PM, akineko akin...@gmail.com wrote: Hello everyone, I'm creating a class which is subclassed from list (Bulit-in type). It works great. However, I'm having a hard time finding a way to set a new value to the object (within the class). There are methods that

Re: How to get millisec/fractional seconds out of a time object ?

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 1:34 PM, da...@bag.python.org wrote: Thanks for help to a beginner. script23 import time import datetime start_time = datetime.datetime.now() time.sleep(0.14) end_time = datetime.datetime.now() datetime.timedelta = end_time

Re: message of Exception

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 6:56 PM, Steven Woody narkewo...@gmail.com wrote: Hi, I am trying define an Exception as below: class MyError(Exception): def __init__(self, message): self.message = message And, I expect that when I raise a MyError as raise MyError, my message the

Re: What is ''r'' in python?

2009-01-06 Thread Chris Rebert
On Tue, Jan 6, 2009 at 10:28 PM, Harish Vishwanath harish.shas...@gmail.com wrote: Hello, I accidentally did this in the shell. ''r'' '' ''r'' == '' True ''r'' == True That is singlequote singlequote r singlequote singlequote. However if I try - ''c'' File stdin, line 1

Re: listdir reports [Error 1006] The volume for a file has been externally altered so that the opened file is no longer valid

2009-01-07 Thread Chris Rebert
PS: Why does the listdir() function add '*.*' to the path? Don't know what you're talking about. It doesn't do any globbing or add *.* to the path. Its exclusive purpose is to list the contents of a directory, so /in a sense/ it does add *.*, but then not adding *.* would make the function

Re: formatted 'time' data in calculations

2009-01-07 Thread Chris Rebert
On Wed, Jan 7, 2009 at 9:35 AM, Ross nos...@forme.thks wrote: There seems to be no shortage of information around on how to use the time module, for example to use time.ctime() and push it into strftime and get something nice out the other side, but I haven't found anything helpful in going

Re: del behavior

2009-01-07 Thread Chris Rebert
On Wed, Jan 7, 2009 at 11:39 AM, Eric Snow es...@verio.net wrote: I was reading in the documentation about __del__ and have a couple of questions. Here is what I was looking at: http://docs.python.org/reference/datamodel.html#object.__del__ What is globals referring to in the following text

Re: del behavior 2

2009-01-07 Thread Chris Rebert
On Wed, Jan 7, 2009 at 11:42 AM, Eric Snow es...@verio.net wrote: I was reading in the documentation about __del__ and have a couple of questions. Here is what I was looking at: http://docs.python.org/reference/datamodel.html#object.__del__ My second question is about the following: It is

Re: del behavior

2009-01-07 Thread Chris Rebert
On Wed, Jan 7, 2009 at 11:55 AM, Eric Snow es...@verio.net wrote: On Jan 7, 12:48 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Jan 7, 2009 at 11:39 AM, Eric Snow es...@verio.net wrote: I was reading in the documentation about __del__ and have a couple of questions. Here is what I

Re: del behavior

2009-01-07 Thread Chris Rebert
On Wed, Jan 7, 2009 at 12:05 PM, MRAB goo...@mrabarnett.plus.com wrote: Chris Rebert wrote: On Wed, Jan 7, 2009 at 11:39 AM, Eric Snow es...@verio.net wrote: I was reading in the documentation about __del__ and have a couple of questions. Here is what I was looking at: http

Re: How to deepcopy a list of user defined lists?

2009-01-08 Thread Chris Rebert
On Wed, Jan 7, 2009 at 11:59 PM, srinivasan srinivas sri_anna...@yahoo.co.in wrote: Hi, I have a class which is a subclass of builtin-type list. #-- class clist(list): def __new__(cls, values, ctor): val

Re: Force exception on attribute write access only one object

2009-01-08 Thread Chris Rebert
On Thu, Jan 8, 2009 at 1:38 AM, Thomas Guettler h...@tbz-pariv.de wrote: Hi, for debugging I want to raise an exception if an attribute is changed on an object. Since it is only for debugging I don't want to change the integer attribute to a property. This should raise an exception:

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Chris Rebert
On Thu, Jan 8, 2009 at 5:53 AM, Sergey Kishchenko void...@gmail.com wrote: In Python empty container equals False in 'if' statements: # prints It's ok if not []: print It's ok Let's create a simple Foo class: class Foo: pass Now I can use Foo objects in 'if' statements: #prints

Re: figuring week of the day....

2009-01-08 Thread Chris Rebert
On Tue, Jan 6, 2009 at 7:56 AM, tekion tek...@gmail.com wrote: Is there a module where you could figure week of the day, like where it starts and end. I need to do this for a whole year. Thanks. The %U time format specifier (Week number of the year) to strftime()

Re: Best practice in organize classes into modules

2009-01-08 Thread Chris Rebert
On Thu, Jan 8, 2009 at 9:09 PM, Steven Woody narkewo...@gmail.com wrote: On Fri, Jan 9, 2009 at 1:02 PM, James Mills prolo...@shortcircuit.net.au wrote: On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody narkewo...@gmail.com wrote: In C++/Java, people usually put one class into one file. What's the

Re: Problem with -3 switch

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 9:17 AM, Aivar Annamaa concat_na...@hotmail.com wrote: Hi I'm getting started with Python and in order to get good habits for Python 3, i'd like to run my Python 2.6.1 with Python 3 warning mode. When i run python -3 and execute statement print 4 then i expect to

Re: Where's Psyco now?

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 10:41 AM, Vicent vgi...@gmail.com wrote: Hello. This is my first message to the list. In this article written in 2002 http://www.ibm.com/developerworks/library/l-psyco.html they talk about Psyco as a module that makes it possible to accelerate Python. Is it still a

Re: spawning pyhon apps...

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 2:47 PM, bruce bedoug...@earthlink.net wrote: hi... toying with an idea.. trying to figure out a good/best way to spawn multiple python scripts from a parent python app. i'm trying to figure out how to determine when all child apps have completed, or to possibly

Re: spawning pyhon apps...

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 3:43 PM, bruce bedoug...@earthlink.net wrote: hi jason forgive me... but in your sample: my_popenobjects = [subprocess.Popen(foo.py, --filename=file %i.txt%x) for x in xrange(10)] are you spawning 'foo.py' 10 times? that can't be right! Indeed, it

Re: Looking for an efficient Python script to download and save a .zip file programmatically

2009-01-10 Thread Chris Rebert
On Sat, Jan 10, 2009 at 9:12 AM, David Shi davidg...@yahoo.co.uk wrote: I am looking for an efficient Python script to download and save a .zip file programmatically (from http or https call). You want urllib.urlretrieve(): http://docs.python.org/library/urllib.html#urllib.urlretrieve Cheers,

Re: urlopen exception

2009-01-10 Thread Chris Rebert
On Sat, Jan 10, 2009 at 9:56 AM, asit lipu...@gmail.com wrote: site=www.bput.org payloads=scriptalert('xss')/script attack= urllib2.urlopen(site+payloads,80).readlines() according to my best knowledge, the above code is correct. but why it throws exceptio Because it's not correct. It's

Re: import relative (with a directory)

2009-01-10 Thread Chris Rebert
On Sat, Jan 10, 2009 at 6:11 PM, rocky rocky.bernst...@gmail.com wrote: Import relative? Recently for fun I've been working on a large Python program. It has many files/modules spread over several directories/submodules. Each module has some demo code at the end that I can use to run or

Re: Does Python really follow its philosophy of Readability counts?

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 1:22 PM, Madhusudan.C.S madhusuda...@gmail.com wrote: I am sorry all I am not here to just blame Python. This is just an introspection of whether what I believe is right. Being a devotee of Python from past 2 years I have been writing only small apps and singing

Re: Object help

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 2:06 PM, killsto kilian...@gmail.com wrote: I have a class called ball. The members are things like position, size, active. So each ball is an object. Class names should use CamelCase, so it should be `Ball`, not `ball`. How do I make the object without specifically

Re: Does Python really follow its philosophy of Readability counts?

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 3:15 PM, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 3:31 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Jan 11, 2009 at 1:22 PM, Madhusudan.C.S madhusuda...@gmail.com wrote: def somemethod(self, arg1): self.c = 20.22 d = some local

Re: Does Python really follow its philosophy of Readability counts?

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 3:41 PM, Paul Rubin http://phr.cx@nospam.invalid wrote: Carl Banks pavlovevide...@gmail.com writes: snip If any objects are mutable, you have to be prepared for objects to mutated outside the initializer. Sure, but why have mutable objects all over the place? And, why

Re: Object help

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 3:49 PM, killsto kilian...@gmail.com wrote: On Jan 11, 2:20 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Sun, 11 Jan 2009 14:06:22 -0800, killsto wrote: I have a class called ball. The members are things like position, size, active. So each

Re: Does Python really follow its philosophy of Readability counts?

2009-01-11 Thread Chris Rebert
On Sun, Jan 11, 2009 at 4:33 PM, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 5:49 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Jan 11, 2009 at 3:15 PM, Carl Banks pavlovevide...@gmail.com wrote: On Jan 11, 3:31 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Jan 11, 2009

Re: Extracting real-domain-name (without sub-domains) from a given URL

2009-01-13 Thread Chris Rebert
On Mon, Jan 12, 2009 at 11:46 PM, S.Selvam Siva s.selvams...@gmail.com wrote: Hi all, I need to extract the domain-name from a given url(without sub-domains). With urlparse, i am able to fetch only the domain-name(which includes the sub-domain also). eg:

Re: Relative performance of comparable regular expressions

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 6:16 AM, Barak, Ron ron.ba...@lsi.com wrote: Hi John, Thanks for the below - teaching me how to fish ( instead of just giving me a fish :-) Now I could definitely get the answers for myself, and also be a bit more enlightened. As for your (2) remark below (on

Re: Read binary file and dump data in

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 12:02 PM, Santiago Romero srom...@gmail.com wrote: Hi. Until now, all my python programs worked with text files. But now I'm porting an small old C program I wrote lot of years ago to python and I'm having problems with datatypes (I think). some C code: fp =

Re: initialising a class by name

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 9:46 PM, Krishnakant krm...@gmail.com wrote: hello all, I have a strange situation where I have to load initiate an instance of a class at run-time with the name given by the user from a dropdown list. Is this possible in python and how? To make things clear, let me

Re: read string in bits

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 11:21 PM, ts thaisi...@gmail.com wrote: hi, is there a way to read a character/string into bits in python? i understand that character is read in bytes. Do i have to write a function to convert it myself into 1010101 or there is a library in python that enable me to do

Re: initialising a class by name

2009-01-13 Thread Chris Rebert
On Tue, Jan 13, 2009 at 11:49 PM, Krishnakant krm...@gmail.com wrote: On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote: Assuming all the classes are in the same module as the main program: instance = vars()[class_name](args, to, init) The classes are not in the same module. Every glade

Re: initialising a class by name

2009-01-14 Thread Chris Rebert
the conversation harder for readers. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com On Tue, 2009-01-13 at 23:55 -0800, Chris Rebert wrote: On Tue, Jan 13, 2009 at 11:49 PM, Krishnakant krm...@gmail.com wrote: On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote: Assuming

Re: initialising a class by name

2009-01-14 Thread Chris Rebert
On Wed, Jan 14, 2009 at 12:36 AM, Krishnakant krm...@gmail.com wrote: On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote: Aside from Steven's excellent idea, to use the getattr() technique with your module scheme you'd probably also need to use __import__() to dynamically import the right

Re: reverse dict lookup Relation class

2009-01-14 Thread Chris Rebert
On Wed, Jan 14, 2009 at 4:30 PM, Aaron Brady castiro...@gmail.com wrote: Hi, this is a continuation of something that comes up now and again about reverse lookups on dictionaries, as well as a follow-up to my pursuit of a Relation class from earlier. For a reverse lookup, you just need two

Re: Python DateTime Manipulation

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 2:19 PM, Kingston kingston...@gmail.com wrote: I have a user input a date and time as a string that looks like: 200901010100 but I want to do a manipulation where I subtract 7 days from it. The first thing I tried was to turn the string into a time with the format

Re: Import functions in current namespace

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 2:35 PM, Markus Schreyer markus.schre...@gmail.com wrote: Hi, we embedded python into our application via Swig. Now we like to wrap the raw API functionality into a nicer more handleable module, but instead of repeating every function in this wrapper i thought about

Re: Beginner: Data type conversion question

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 9:09 PM, flagg ianand0...@gmail.com wrote: I am still fairly new to python and programming in general. My question is regarding data conversion, I am working on a script that will edit dns zone files, one of the functions i wrote handles updating the serial number.

Re: English-like Python

2009-01-15 Thread Chris Rebert
On Thu, Jan 15, 2009 at 5:02 PM, The Music Guy music...@alphaios.net wrote: Just out of curiousity, have there been any attempts to make a version of Python that looks like actual English text? I mean, so much of Python is already based on the English language that it seems like the next

Re: Class decorator with argument

2009-01-16 Thread Chris Rebert
On Fri, Jan 16, 2009 at 12:15 PM, mk mrk...@gmail.com wrote: Hello, I wrote this class decorator with argument: class ChangeDoc(object): def __init__(self, docstring): self.docstring = docstring def __call__(self, func): func.__doc__ =

Re: dynamic module import?

2009-01-16 Thread Chris Rebert
On Fri, Jan 16, 2009 at 3:03 PM, Lawson Hanson lawsonhan...@optusnet.com.au wrote: Is it possible to import a module of Python code where I do not know the name of the module until run-time? Yes. Use the __import__() built-in function. See

Re: A java hobbyist programmer learning python

2009-01-17 Thread Chris Rebert
On Sat, Jan 17, 2009 at 5:11 PM, elhombre elhm...@ozemail.com.au wrote: Hello, below is my first fragment of working python code. As you can see it is very java like as that is all I know. Is this the right approach to be taking? Should I be taking a different approach? Thanks in advance.

Re: A java hobbyist programmer learning python

2009-01-17 Thread Chris Rebert
On Sat, Jan 17, 2009 at 5:53 PM, Paul Rubin http://phr.cx@nospam.invalid wrote: Chris Rebert c...@rebertia.com writes: Rather than have a long if-elif-else chain like this, you can use a dictionary with functions as values. For example: def add(x, y): return x + y These functions

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 2:56 AM, andrew cooke and...@acooke.org wrote: Context - http://docs.python.org/3.0/reference/datamodel.html?highlight=data model#object.__iadd__ Just a suggestion I thought I'd throw out... There's a restriction in the language implementation on exactly what can go

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 3:42 AM, andrew cooke and...@acooke.org wrote: Therefore, Python requires you to rewrite the code in some other way that makes your intentions more clear. For instance, why not use the operator instead? Right, but you're guessing what the context is. Within a DSL it

Re: How to use *.py modules instead of *.pyc?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 5:13 PM, dsblizz...@gmail.com wrote: How to use *.py modules instead of *.pyc or automatically recompile all modules each time I change *.py files? IIRC, you shouldn't need to worry about this. Python checks the modification times on the .py and .pyc files and if the

Re: How to use *.py modules instead of *.pyc?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 5:13 PM, dsblizz...@gmail.com wrote: How to use *.py modules instead of *.pyc or automatically recompile all modules each time I change *.py files? Thank you in advance. Also, just for the sake of completeness (since John and I have shown that your real problem lies

Re: Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Chris Rebert
On Mon, Jan 19, 2009 at 4:04 AM, Phillip B Oldham phillip.old...@gmail.com wrote: Is it possible to automatically run an operation on a object's attribute when reading? For instance, if I have the following: class Item(object): tags = ['default','item'] item = Item() desc = item.tags

Re: Can I run an operation on an object's attribute when reading?

2009-01-19 Thread Chris Rebert
On Mon, Jan 19, 2009 at 4:22 AM, Phillip B Oldham phillip.old...@gmail.com wrote: On Mon, Jan 19, 2009 at 12:15 PM, Chris Rebert c...@rebertia.com wrote: Assuming I'm interpreting you correctly (you're going to have to use something like a getter): Thanks, but I'm looking for a way to do

Re: Logging help

2009-01-19 Thread Chris Rebert
On Mon, Jan 19, 2009 at 11:36 AM, koranthala koranth...@gmail.com wrote: Hi, Is it possible somehow to have the logging module rotate the files every time I start it. Basically, I can automatically rotate using RotatingFileHandler; Now I want it rotated every time I start the program too.

Re: Overloading Methods

2009-01-20 Thread Chris Rebert
On Tue, Jan 20, 2009 at 10:18 AM, MRAB goo...@mrabarnett.plus.com wrote: K-Dawg wrote: Can you overload methods in Python? Can I have multiple __inits__ with different parameters passed in? Simple answer: no. More complicated answer: Yes, with some caveats. You usually don't need to

Re: Overloading Methods

2009-01-20 Thread Chris Rebert
myself to think a little differently. Kevin On Tue, Jan 20, 2009 at 1:41 PM, Chris Rebert c...@rebertia.com wrote: On Tue, Jan 20, 2009 at 10:18 AM, MRAB goo...@mrabarnett.plus.com wrote: K-Dawg wrote: Can you overload methods in Python? Can I have multiple __inits__ with different

Re: unzip array of arrays?

2009-01-22 Thread Chris Rebert
On Thu, Jan 22, 2009 at 2:04 PM, Tobiah t...@tobiah.org wrote: Although it's trivial to program, I wondered whether there was a builtin or particularly concise way to express this idea: a = [(1, 2), (3, 4), (5, 6)] field[a, 2] [2, 4, 6] where field() is some made up function. Python 2.6

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Chris Rebert
On Thu, Jan 22, 2009 at 5:41 PM, Giovanni Bajo ra...@develer.com wrote: On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: The collections module in Python 2.7 and Python 3.1 has gotten a new Counter class that works like bags and multisets in other languages. I've adapted it for

Re: What is intvar?

2009-01-22 Thread Chris Rebert
On Thu, Jan 22, 2009 at 6:38 PM, W. eWatson notval...@sbcglobal.net wrote: I'm looking at someone's code in which invar() is used fairly often. Apparently, it's a Tkinter method. Here's a use: def body(self,master): self.title(Display Settings) self.colorVar = IntVar()

Re: The First Law Of comp.lang.python Dynamics

2009-01-22 Thread Chris Rebert
On Thu, Jan 22, 2009 at 9:39 PM, Kay Schluehr kay.schlu...@gmx.net wrote: Whatever sufficiently sophisticated topic was the initially discussed it ends all up in a request for removing reference counting and the GIL. +1 QOTW - Chris -- Follow the path of the Iguana... http://rebertia.com --

Re: Executing WinXP commands using os module

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 3:50 AM, pranav pra...@gmail.com wrote: Greetings, I am writing a code to perform operations like checkout, check-in and others for SS. (SS is the command line utility for Visual SafeSource, VSS). I am familiar with all the commands for this purpose. I know li'l python

Re: Need script to download file from a server using python script

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 3:00 AM, Murali Murali muralimkrisha...@yahoo.com wrote: Hi, I am fairly new to python and i am looking for a python script to download file(latest build) from the server. But, the build name changes daily. For Ex: today the build URL will be

Re: writing pickle function

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 6:48 AM, perfr...@gmail.com wrote: hello, i am using nested defaultdict from collections and i would like to write it as a pickle object to a file. when i try: from collections import defaultdict x = defaultdict(lambda: defaultdict(list)) and then try to write to

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 11:19 AM, aha aquil.abdul...@gmail.com wrote: Hello All, I've been charged with developing an XML configuration file format, for one of the applications that my company develops. (Yes, I know it would have been easier to just use the configuration file format as

Re: var is None vs. var == None

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 11:58 AM, Gerald Britton gerald.brit...@gmail.com wrote: Hi -- Some time ago I ran across a comment recommending using var is None instead of var == None (also var is not None, etc.) My own testing indicates that the former beats the latter by about 30% on average.

Re: unzip array of arrays?

2009-01-23 Thread Chris Rebert
On Fri, Jan 23, 2009 at 12:37 PM, Tobiah t...@tobiah.org wrote: On Thu, 22 Jan 2009 14:13:34 -0800, Chris Rebert wrote: On Thu, Jan 22, 2009 at 2:04 PM, Tobiah t...@tobiah.org wrote: Although it's trivial to program, I wondered whether there was a builtin or particularly concise way

Re: Function arguments

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 1:03 AM, brasse thebra...@gmail.com wrote: Hello! Is there any way that I can get at all the arguments passed to a function as a map without using keyword arguments? def foo(a, b, c): # Can I access all the arguments in a collection somewhere? You can use

Re: Function arguments

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 1:34 AM, brasse thebra...@gmail.com wrote: On Jan 26, 10:11 am, Chris Rebert c...@rebertia.com wrote: On Mon, Jan 26, 2009 at 1:03 AM, brasse thebra...@gmail.com wrote: Hello! Is there any way that I can get at all the arguments passed to a function as a map

Re: Web services

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 8:11 AM, loial jldunn2...@googlemail.com wrote: I am trying to learn about web services and how to interface with a 3rd party web service from python. Can anyone point me at an idiots guide/tutorial for someone who is new to web services? The XML-RPC client module in

Re: Exec woes

2009-01-27 Thread Chris Rebert
On Tue, Jan 27, 2009 at 9:34 AM, Christian Heimes li...@cheimes.de wrote: Hendrik van Rooyen schrieb: It starts with the conspiracy of silence at the interactive prompt: Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for

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

2009-01-27 Thread Chris Rebert
On Tue, Jan 27, 2009 at 1:16 PM, Reckoner recko...@gmail.com 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_changes_the_properties() which

Re: Python-list Digest, Vol 64, Issue 644

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 1:08 AM, M Kumar tomanis...@gmail.com wrote: is python a pure objected oriented language? Firstly: (A) Replying to Digests rather than individual posts is very discouraged. (B) The proper way to start a new thread by emailing python-list@python.org (as it says in the very

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 2:01 AM, M Kumar tomanis...@gmail.com wrote: Object oriented languages doesn't allow execution of the code without class objects, what is actually happening when we execute some piece of code, is it bound to any class? That's not really the standard definition of

Re: slicings: 3 questions

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 10:01 AM, Alan G Isaac alan.is...@gmail.com wrote: 1. I seem not to understand something obvious at http://docs.python.org/3.0/reference/expressions.html#slicings (I assume I'm just not reading this right.) What is an example of a slicing using a slice_list? There's

Re: Can't understand what python wants from me

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 1:50 PM, Oleksiy Khilkevich g...@asu.ntu-kpi.kiev.ua wrote: Hello, everyone, This may be a totally noob question, but since I am one, so here is it. I have the following code (not something much of): http://paste.debian.net/27204 The current code runs well, but the

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 7:31 PM, Steven D'Aprano ste...@remove.this.cybersource.com.au 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__ type 'function

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 9:56 PM, Hung Vo hungv...@gmail.com wrote: snip 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

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 10:25 PM, alex23 wuwe...@gmail.com wrote: On Jan 30, 4:15 pm, Chris Rebert c...@rebertia.com 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

Re: Want to write a script to do the batch conversion from domain name to IP.

2009-01-30 Thread Chris Rebert
On Fri, Jan 30, 2009 at 4:27 AM, Hongyi Zhao hongyi.z...@gmail.com wrote: Hi all, Suppose I've the entries like the following in my file: -- 116.52.155.237:80 ip-72-55-191-6.static.privatedns.com:3128 222.124.135.40:80 217.151.231.34:3128 202.106.121.134:80

Re: import reassignment different at module and function scope

2009-01-30 Thread Chris Rebert
On Fri, Jan 30, 2009 at 11:31 PM, Brendan Miller catph...@catphive.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 If I: import sys sys = sys.version This executes find but: import sys def f(): sys = sys.version This gives an error indicating that the sys on the right

Re: What is wrong in my list comprehension?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 3:22 AM, Hussein B hubaghd...@gmail.com wrote: Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime start = datetime.now() print start

Re: is python Object oriented??

2009-02-01 Thread Chris Rebert
On Sat, Jan 31, 2009 at 9:08 AM, thmpsn@gmail.com wrote: On Jan 30, 12:15 am, Chris Rebert c...@rebertia.com wrote: - Python supports encapsulation. Prefixing an attribute/method with an underscore indicates that other programmers should treat it as 'private'. However, unlike BD languages

Re: database wrapper ?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 2:56 PM, Stef Mientki stef.mien...@gmail.com wrote: hello, Until now I used a simple wrapper around pysqlite and pyodbc to manage my databases. Now I'm looking for a better solution, because I've to support a (for this moment) unknown database, and I'm not the one who

Re: question about Z=[[x for y in range(1, 2) if AList[x]==y] for x in range(0,5)]

2009-02-01 Thread Chris Rebert
On Fri, Jan 30, 2009 at 5:33 PM, Vincent Davis vinc...@vincentdavis.net wrote: Z=[[x for y in range(1,2) if AList[x]==y] for x in range(0,5)] I am not sure how to ask this but which for is looped first? I could test but was wondering if there was a nice explanation I could apply to future

Re: AssertionError not caught?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 6:31 PM, LX lxk...@gmail.com wrote: This one has me mystified good! This works (print statement is executed as the Exception is caught) as advertised: try: raise AssertionError except AssertionError: print caught AssertionError But this one

Re: call other program

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 7:35 PM, JuanPablo jabar...@gmail.com wrote: hi, I have a newbie question. In bash is posible call other program, send and recieve message with this. example: $ python output EOF print hello world EOF $ cat output hello world in python exist some similar ?

Re: Combining several text files

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 9:48 AM, Eric eric.sh...@gmail.com wrote: This is my first post, so please advise if I'm not using proper etiquette. I've actually searched around a bit and while I think I can do this, I can't think of a clean elegant way. I'm pretty new to Python, but from what I've

Re: how to create data to dump into yaml file

2009-02-02 Thread Chris Rebert
On Sun, Feb 1, 2009 at 11:41 PM, sibt...@infotechsw.com wrote: hi I have to create a yaml file using my list of objects.shall i need to create a string using my objects and then load and dump that string or is there any other way to create the yaml file. i want a yaml file to be created

Re: Exception error when accessing the class variable at the termination of the program

2009-02-02 Thread Chris Rebert
On Sun, Feb 1, 2009 at 11:52 PM, jwal...@vsnl.net wrote: Hi All, Here is a sample piece of code with which I am having a problem, with Python version 2.4.4 class Person: Count = 0 # This represents the count of objects of this class def __init__(self, name): self.name

Re: importing module-performance

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva s.selvams...@gmail.com wrote: Hi all, I have a small query, Consider there is a task A which i want to perform. To perform it ,i have two option. 1)Writing a small piece of code(approx. 50 lines) as efficient as possible. 2)import a suitable

Re: global variable confusion

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 10:25 PM, Robert D.M. Smith robert.dm.sm...@gmail.com wrote: I have a question on global variables and how to use them. I have 2 files; a.py b.py # a.py - myvar = { 'test' : '123' } # --- # b.py - from a import myvar def test(): a.myvar = {

Re: Varibles -- copies and references

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 10:02 PM, Ferdinand Sousa ferdinandso...@gmail.com wrote: Hi Some weeks back I had been following the thread Why can't assign to function call. Today, I saw the function scope thread, and decided I should ask about the behaviour below:

Re: subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 1:22 AM, Helmut Jarausch jarau...@skynet.be wrote: Hi, using e.g. import subprocess Package='app-arch/lzma-utils' EQ=subprocess.Popen(['/usr/bin/equery','depends',Package],stdout=subprocess.PIPE) EQ_output= EQ.communicate()[0] EQ_output is a string containing

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 5:02 PM, todp...@hotmail.com todp...@hotmail.com wrote: Using while loop and if statement, I'm trying to get Python to tell me whether there are even or odd number of 1's in a binary representation. For example, if I give Python a 0111, then I want it to say that the

Re: How to trigger a smart link?

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 5:16 PM, Muddy Coder cosmo_gene...@yahoo.com wrote: Hi All, Using urllib2 can trigger CGI script in server side. However, I encountered a problem of the so-called smart link. When a fairly large site, the server needs to track the identifier of each request from

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Chris Rebert
A byte is *not* a Python type. My question was what *Python type* (i.e. bytes (which is distinctly different from the abstract notion of a byte), str/unicode, int, etc...) you were using for you binary representation, which you still haven't answered. Also, please don't reply by top-posting

<    1   2   3   4   5   6   7   8   9   10   >