On 07/01/10 23:19, Stephen Hansen wrote:
>>
>> As long as setattr() exists in Python, that will be not so ordinary. :)
>
> setattr is perfectly ordinary.
If you think setattr() is as ordinary as a trivial assignment, I will
argue with you, this is personal taste.
However, I think setattr() is a
On 07/01/10 22:53, Stephen Hansen wrote:
>
> One uses assignment syntax when the name of the attribute they are
> setting is known at the time when one writes the code.
>
> One uses the setattr function when the name of the attribute is not
> known until runtime.
>
> The difference has *nothing a
On 06/28/10 17:43, Bruno Desthuilliers
wrote:
> Carl Banks a écrit :
>> On Jun 27, 3:49 am, Bruno Desthuilliers
>> wrote:
>>> WANG Cong a écrit :
>>>
>>>> On 06/26/10 00:11, Neil Hodgson wrote:
>>>>> WANG Cong:
>>&g
On 06/27/10 09:06, Steven D'Aprano wrote:
>> In that situation, certainly: adding an attribute on the fly to that
>> formal definition seems entirely strange and special of an activity. But
>> that's only because you *chose* to *see* and *use* the object that way.
>> The "special"ness of the acti
On 07/01/10 13:49, Stephen Hansen wrote:
Hi, Stephen,
>>
>> It may not be "the" primary concern, but elegance certainly is *a*
>> primary concern.
>
> I concur.
>
> Its not explicitly stated, but it is the Zen 0. This is further
> supported by its implied presence in many of the Axioms and Truth
On 06/30/10 01:20, Stephen Hansen wrote:
>> But if so why setattr() still exists? What is it for if we can do the
>> same thing via assignments? Also, in order to be perfect, Python should
>> accept to add dynamic attributes dynamically, something like PEP
>> 363. That doesn't happen.
>
> What do
On 06/30/10 01:25, Ethan Furman wrote:
>> But if so why setattr() still exists? What is it for if we can do the
>> same thing via assignments? Also, in order to be perfect, Python should
>> accept to add dynamic attributes dynamically, something like PEP
>> 363. That doesn't happen.
>
> Setattr a
On 06/27/10 12:01, Carl Banks wrote:
> On Jun 25, 8:24 pm, WANG Cong wrote:
>> Understand, but please consider my proposal again, if we switched to:
>>
>> setattr(foo, 'new_attr', "blah")
>>
>> by default, isn't Python still dynamic as
On 06/29/10 17:48, Andre Alexander Bell wrote:
> On 06/25/2010 03:15 PM, WANG Cong wrote:
>> 1) Modifying a class attribute is metaprogramming, and this is modifying
>> a class, i.e. adding a new attribute to it, thus this should belong
>> to metaprogramming. (I know, strict
On 06/25/10 20:22, Ian Kelly wrote:
> On Fri, Jun 25, 2010 at 12:51 PM, Stephen Hansen
> wrote:
>>> Using assignments to create an attribute hides metaprogramming behide,
>>> while using delattr() exposes it.
>>
>> I don't understand what you're saying here either.
>
> I think he's saying that w
On 06/25/10 22:11, Mark Lawrence wrote:
> On 25/06/2010 19:23, WANG Cong wrote:
>> On 06/25/10 14:31, Richard Thomas wrote:
>>
>>
>>
>>>
>>> If you desperately want to limit the attribute assignments that can be
>>> performed on an obje
On 06/25/10 19:38, Ethan Furman wrote:
> WANG Cong wrote:
>> On 06/25/10 15:34, Bruno Desthuilliers
>> wrote:
>>
>>> WANG Cong a écrit :
>>>> Hi, list!
>>>>
>>>> I have a doubt about the design of dynamic attribute creation by
&
On 06/26/10 00:11, Neil Hodgson wrote:
> WANG Cong:
>
>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>> this is and should be implemented by inherence.
>
>Most object oriented programming languages starting with Smalltalk
> have allowed adding
On 06/26/10 03:31, Carl Banks wrote:
> On Jun 25, 6:15 am, WANG Cong wrote:
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, we are able to create a new attribute of
On 06/25/10 14:31, Richard Thomas wrote:
>
> If you desperately want to limit the attribute assignments that can be
> performed on an object you can set the __slots__ attribute of its
> type. However, the Python ethos has always been to restrict as little
> as necessary to provide the tools it
On 06/25/10 15:34, Bruno Desthuilliers
wrote:
> WANG Cong a écrit :
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, we are able to create a new attribute of
On 06/25/10 17:25, Steven D'Aprano wrote:
> On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote:
>
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, w
Hi, list!
I have a doubt about the design of dynamic attribute creation by
assignments in Python.
As we know, in Python, we are able to create a new attribute of
a class dynamically by an assignment:
>>> class test: pass
...
>>> test.a = "hello"
>>> test.a
'hello'
>>>
However, I still don't
alternative would be to write
> a function with two parameters that takes a tuple of names and the code
> quoted as a string as arguments. It would insert the global statement
> into the string, execute it, and return the function.
Thank you for your elaborate explanation :)
Regards,
Cong.
--
http://mail.python.org/mailman/listinfo/python-list
hon 2.x). I'd like to hear your opinions. Thank you.
Regards,
Cong.
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina wrote:
> En Mon, 08 Dec 2008 12:34:03 -0200, Cong Ma <[EMAIL PROTECTED]> escribió:
>
>> I'm writing a program that pickles an instance of a custom subclass of
>> datetime.tzinfo. I followed the guides given in the Library Reference
>> (vers
methods is better? Both seems
to unpickle to the correct result, but are there subtle side-effects? Or there
are better solutions?
Regards,
Cong.
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
> for \
> Entry \
> in \
> sorted \
> (
> f for f in os.listdir(PatchesDir) if PatchDatePat.search(f) !=
> None
> ) \
> :
> Patch = (open,
> gzip.GzipFile)[Entry.endswith(".gz")](os.path.join(PatchesDir, Entry), "r
Nick Craig-Wood wrote:
> Here is how you do exactly that in python using ctypes
>
> from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
> from ctypes.util import find_library
>
> class c_dir(Structure):
> """Opaque type for directory entries, corresponds to struct DIR"""
> c_dir_p =
alex23 wrote:
> On Nov 26, 3:26 pm, greg <[EMAIL PROTECTED]> wrote:
>> os.O_DIRECTORY must be fairly new -- it doesn't exist
>> in my 2.5 installation. But os.O_RDONLY seems to work
>> just as well for this purpose.
>
> Which OS are you using?
>
> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
alex23 wrote:
> On Nov 26, 12:31 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote:
>> Is this what you want?
>>
>> ofiles = [open(x) for x in os.listdir(os.getcwd())]
>
> 'open' returns a "file object", whereas the OP is after "file
> descriptors", which are returned by 'os.open'.
>
> --
> http:/
r0g wrote:
> Cong Ma wrote:
>> Dear all,
>>
>> Can you give me some hint on getting a directory file descriptor in Python?
>> Besides, what's good about os.fchdir() if I can't get a directory fd in the
>> first place?
>>
>> Thanks for
Dear all,
Can you give me some hint on getting a directory file descriptor in Python?
Besides, what's good about os.fchdir() if I can't get a directory fd in the
first place?
Thanks for your reply.
Regards,
Cong.
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 18, 11:01 pm, Kris Kennaway <[EMAIL PROTECTED]> wrote:
> Calvin Spealman wrote:
> > Upload, wait, and google them.
>
> > Seriously tho, aside from using a real indexer, I would build a set of
> > thewordsI'mlookingfor, and then loop over each file, looping over
> > thewordsand doing quick ch
M$ is evil!
--
http://mail.python.org/mailman/listinfo/python-list
30 matches
Mail list logo