Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 4:51 PM, Andrew Robinson wrote: > I really don't think doing a shallow copy of lists would break anyone's > program. Well, it's a change, a semantic change. It's almost certainly going to break _something_. But for the sake of argument, we can suppose that the change could

Re: Multi-dimensional list initialization

2012-11-05 Thread Andrew Robinson
On 11/05/2012 06:30 PM, Oscar Benjamin wrote: On 6 November 2012 02:01, Chris Angelico wrote: On Tue, Nov 6, 2012 at 12:32 PM, Oscar Benjamin wrote: I was just thinking to myself that it would be a hard thing to change because the list would need to know how to instantiate copies of all the

Re: How to only get a list of the names of the non-directory files in current directory ('.')?

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 4:19 PM, iMath wrote: > How to only get a list of the names of the non-directory files in current > directory ('.')? > (Note excluding its subdirectories ). > > I need the code : ) Start by getting a list of names of everything in the current directory. Then filter that l

How to only get a list of the names of the non-directory files in current directory ('.')?

2012-11-05 Thread iMath
How to only get a list of the names of the non-directory files in current directory ('.')? (Note excluding its subdirectories ). I need the code : ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Steven D'Aprano
On Mon, 05 Nov 2012 17:39:35 +1100, Chris Angelico wrote: > On Mon, Nov 5, 2012 at 5:10 PM, rusi wrote: >> Among people who know me, I am a linux nerd: My sister scolded me >> yesterday because I put files on her computer without spaces: >> DoesAnyoneWriteLikeThis?!?! > > My filenames seldom hav

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Steven D'Aprano
On Mon, 05 Nov 2012 14:47:47 -0500, Dennis Lee Bieber wrote: >> Don't most OSes allow non-printing characters in filenames? VMS and >> Unix always have. AFAIK, there are only two characters that can't >> appear in a Unix filename: '\x00' and '/'. > > But can you /enter/ them with common k

Re: problem with eval and time

2012-11-05 Thread Dave Angel
On 11/05/2012 11:29 PM, Wincent wrote: (Please don't top-post. it messes everything up. And your use of Google-groups is making everything double-spaced) > Thanks. > > I fetch data from social networking sites and want to mark the time of > access. I store all the information in a redis databa

Re: problem with eval and time

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 3:29 PM, Wincent wrote: > Thanks. > > I fetch data from social networking sites and want to mark the time of > access. I store all the information in a redis database, which converts > everything into strings and I need to convert those strings back to original > python o

Re: Coordination between developers in the Python project

2012-11-05 Thread Steven D'Aprano
On Mon, 05 Nov 2012 14:09:08 -0500, Terry Reedy wrote: > On 11/1/2012 4:49 PM, Tengy Td wrote: >> Hello, >> >> >> I am a French student and I am currently realizing my final thesis in >> the field of Free/libre open source software. > > If you really are what you claim, you should give more detai

Re: problem with eval and time

2012-11-05 Thread Wincent
Thanks. I fetch data from social networking sites and want to mark the time of access. I store all the information in a redis database, which converts everything into strings and I need to convert those strings back to original python objects when analyzing the data. Best Regards On Tuesday,

Re: problem with eval and time

2012-11-05 Thread alex23
On Nov 6, 1:32 pm, Wincent wrote: > Dear all, I would like to convert tstr to representation > of time, but encounter the following error. Is there a > simple way to get what I want? Thanks. > > >>> import time > >>> tstr = str(time.localtime()) > >>> eval(tstr) > > Traceback (most recent call las

Re: How to improve the usability of nested packages

2012-11-05 Thread Rouslan Korneychuk
On 11/02/2012 12:11 PM, Michael Schwarz wrote: … which doesn't work. Some of the modules reference other modules in the same package. I'm not talking about cyclic references, but, for example, the "dialog" module uses the "transaction" module. The problem is that the "dialog" module uses the same

problem with eval and time

2012-11-05 Thread Wincent
Dear all, I would like to convert tstr to representation of time, but encounter the following error. Is there a simple way to get what I want? Thanks. >>> import time >>> tstr = str(time.localtime()) >>> eval(tstr) Traceback (most recent call last): File "", line 1, in File "", line 1, in T

Re: Multi-dimensional list initialization

2012-11-05 Thread Oscar Benjamin
On 6 November 2012 02:01, Chris Angelico wrote: > On Tue, Nov 6, 2012 at 12:32 PM, Oscar Benjamin > wrote: >> I was just thinking to myself that it would be a hard thing to change >> because the list would need to know how to instantiate copies of all >> the different types of the elements in the

Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 12:32 PM, Oscar Benjamin wrote: > I was just thinking to myself that it would be a hard thing to change > because the list would need to know how to instantiate copies of all > the different types of the elements in the list. Then I realised it > doesn't. It is simply a case

Re: Multi-dimensional list initialization

2012-11-05 Thread Oscar Benjamin
On 5 November 2012 09:13, Hans Mulder wrote: > On 5/11/12 07:27:52, Demian Brecht wrote: >> So, here I was thinking "oh, this is a nice, easy way to initialize a 4D >> matrix" >> (running 2.7.3, non-core libs not allowed): >> >> m = [[None] * 4] * 4 >> >> The way to get what I was after was: >> >

Re: Coordination between developers in the Python project

2012-11-05 Thread Chris Angelico
On Fri, Nov 2, 2012 at 7:49 AM, Tengy Td wrote: > It would be a great help for me if you could answer a short online survey > (it should take approximately 5 minutes). > > This survey is designed to reach a better understanding of the cooperation > and coordination between developers in Free/libre

Re: accepting file path or file object?

2012-11-05 Thread Cameron Simpson
On 05Nov2012 10:54, andrea crotti wrote: | Quite often I find convenient to get a filename or a file object as | argument of a function, and do something as below: I tend to do this: def f(fp): if isinstance(fp, str): with open(fp) as subfp: return f(subfp) ... main code

Re: Multi-dimensional list initialization

2012-11-05 Thread Joshua Landau
On 5 November 2012 06:27, Demian Brecht wrote: > >>> a = [None] * 4 > >>> a[0] = 'a' > >>> a > ['a', None, None, None] > > >>> m = [[None] * 4] * 4 > >>> m[0][0] = 'm' > >>> m > [['m', None, None, None], ['m', None, None, None], ['m', None, None, > None], ['m', None, None, None]] > > Is this expe

Re: Coordination between developers in the Python project

2012-11-05 Thread Chris Angelico
On Tue, Nov 6, 2012 at 6:09 AM, Terry Reedy wrote: >> I would like to remind you that the participation is absolutely >> anonymous and voluntary, and you can quit it at any time. Your answers >> will be strictly confidential and will be used only for research purpose >> (no commercial use of any i

Re: Proper place for everything

2012-11-05 Thread rurpy
On 11/02/2012 04:12 PM, Steven D'Aprano wrote: > On Fri, 02 Nov 2012 11:51:29 -0700, Jason Benjamin wrote: > >> On another note, it appears that Google (the only archive I can find for >> this group) only has a little under 400 messages archived for this >> group, > > Google Groups is poison. If

Re: Obnoxious postings from Google Groups

2012-11-05 Thread rurpy
On 11/04/2012 04:13 AM, Jamie Paul Griffin wrote: > / ru...@yahoo.com wrote on Fri 2.Nov'12 at 11:39:10 -0700 / > >> (I also hope I haven't just been suckered by a troll attempt, >> windows/unix is better then unix/windows being an age-old means of >> trolling.) > > No, i'm not a "troll". I was

Re: py2exe with python 3.x

2012-11-05 Thread Kwpolska
On Mon, Nov 5, 2012 at 8:34 PM, Monkey wrote: > Hi, > i wonderd if there is a way to convert a py-file to a exe-file with version > 3.x of python. > > I know that it was possible till version 2.7.x. But is there a way to do it > in version 3.x? > > Yours sincerely, > Monkey > -- > http://mail.py

py2exe with python 3.x

2012-11-05 Thread Monkey
Hi, i wonderd if there is a way to convert a py-file to a exe-file with version 3.x of python. I know that it was possible till version 2.7.x. But is there a way to do it in version 3.x? Yours sincerely, Monkey -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between range and xrange ??

2012-11-05 Thread Terry Reedy
On 11/5/2012 9:23 AM, inshu chauhan wrote: what is the difference between range and xrange.. both seem to work the same. ? >>> range(3) [0, 1, 2] >>> xrange(3) xrange(3) You should read the appropriate manual entries before asking trivial questions. They say pretty clearly that range returns

Re: accepting file path or file object?

2012-11-05 Thread Terry Reedy
On 11/5/2012 5:54 AM, andrea crotti wrote: Quite often I find convenient to get a filename or a file object as argument of a function, and do something as below: def grep_file(regexp, filepath_obj): """Check if the given text is found in any of the file lines, take a path to a file or

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Grant Edwards
On 2012-11-05, Dennis Lee Bieber wrote: > On Mon, 5 Nov 2012 17:39:35 +1100, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> It's nothing to do with operating system. File names are names, and >> spaces in them are seldom worth the hassle unless you manipulate thos

Re: accepting file path or file object?

2012-11-05 Thread Grant Edwards
On 2012-11-05, andrea crotti wrote: > Quite often I find convenient to get a filename or a file object as > argument of a function, and do something as below: > > def grep_file(regexp, filepath_obj): [...] > if isinstance(filepath_obj, basestring): > fobj = open(filepath_obj) > el

Re: Multi-dimensional list initialization

2012-11-05 Thread Demian Brecht
On 2012-11-04, at 11:07 PM, Chris Rebert wrote: > However, unlike a list object (as in your latter example), the object > `None` is completely immutable (and what's more, a singleton value), > so you just-so-happen *not to be able to* run into the same problem of > mutating an object (assignment

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Grant Edwards
On 2012-11-05, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> It's nothing to do with operating system. File names are names, and >> spaces in them are seldom worth the hassle unless you manipulate those >> files solely using a GUI. > > That's a very ascii-esqe attitude. In a full

Re: Multi-dimensional list initialization

2012-11-05 Thread Demian Brecht
On 2012-11-04, at 10:44 PM, Andrew Robinson wrote: > but I think you meant: > > m = [[None] * 4, [None] * 4, [None] * 4, [None] *4 ] > rather than: > m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] Yes, I meant the former, thanks for catching the typo. Demian Brecht @demianbrecht http://d

Re: Difference between range and xrange ??

2012-11-05 Thread Joel Goldstick
in python 2.x xrange is a generator and range returns a list. In python 3.x xrange is renamed to range replacing the list function with the generator On Mon, Nov 5, 2012 at 9:23 AM, inshu chauhan wrote: > what is the difference between range and xrange.. both seem to work the > same. ? And whi

Re: Difference between range and xrange ??

2012-11-05 Thread Dave Angel
On 11/05/2012 09:23 AM, inshu chauhan wrote: > what is the difference between range and xrange.. both seem to work the > same. ? And which should be used where and in what situations.. ?? > > One difference is that from versions of Python 3.0 and later, xrange doesn't exist, and range takes over

Difference between range and xrange ??

2012-11-05 Thread inshu chauhan
what is the difference between range and xrange.. both seem to work the same. ? And which should be used where and in what situations.. ?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Chris Angelico
On Mon, Nov 5, 2012 at 11:56 PM, Roy Smith wrote: > That's a very ascii-esqe attitude. In a fully unicode world, I could > easily see using U+00A0 (NO-BREAK SPACE) in file names, and still have > space-delimited CLI work just fine. > Oh, do you have a "U+00A0-bar" on your keyboard? ChrisA -- h

Re: accepting file path or file object?

2012-11-05 Thread Peter Otten
andrea crotti wrote: > 2012/11/5 Peter Otten <__pete...@web.de>: >> I sometimes do something like this: >> @contextmanager >> def xopen(file=None, mode="r"): >> if hasattr(file, "read"): >> yield file elif file == "-" or file is None: # add file=None handling >> if "w"

Re: accepting file path or file object?

2012-11-05 Thread Ulrich Eckhardt
Am 05.11.2012 11:54, schrieb andrea crotti: Quite often I find convenient to get a filename or a file object as argument of a function, and do something as below: def grep_file(regexp, filepath_obj): """Check if the given text is found in any of the file lines, take a path to a file or

Re: accepting file path or file object?

2012-11-05 Thread andrea crotti
2012/11/5 Peter Otten <__pete...@web.de>: > I sometimes do something like this: > > $ cat xopen.py > import re > import sys > from contextlib import contextmanager > > @contextmanager > def xopen(file=None, mode="r"): > if hasattr(file, "read"): > yield file > elif file == "-": >

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Roy Smith
In article , Chris Angelico wrote: > It's nothing to do with operating system. File names are names, and > spaces in them are seldom worth the hassle unless you manipulate those > files solely using a GUI. That's a very ascii-esqe attitude. In a fully unicode world, I could easily see using U

Re: accepting file path or file object?

2012-11-05 Thread Peter Otten
andrea crotti wrote: > Quite often I find convenient to get a filename or a file object as > argument of a function, and do something as below: > > def grep_file(regexp, filepath_obj): > """Check if the given text is found in any of the file lines, take > a path to a file or an opened fil

Re: Multi-dimensional list initialization

2012-11-05 Thread wxjmfauth
Le lundi 5 novembre 2012 07:28:00 UTC+1, Demian Brecht a écrit : > So, here I was thinking "oh, this is a nice, easy way to initialize a 4D > matrix" (running 2.7.3, non-core libs not allowed): > > > > m = [[None] * 4] * 4 > > > > The way to get what I was after was: > > > > m = [[None] *

Re: Multi-dimensional list initialization

2012-11-05 Thread Hans Mulder
On 5/11/12 07:27:52, Demian Brecht wrote: > So, here I was thinking "oh, this is a nice, easy way to initialize a 4D > matrix" > (running 2.7.3, non-core libs not allowed): > > m = [[None] * 4] * 4 > > The way to get what I was after was: > > m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]]

Re: python destructor

2012-11-05 Thread Ferencik Ioan
On Monday, November 5, 2012 8:51:00 AM UTC+2, Ferencik Ioan wrote: > Hello there folks, > > > > I have a bit of a special issue. > > I'll start by disclosing myself for what i am doing. I am a postgraduate > student and I really have good reasons to do what I am doing. At least i > think so.

Re: Multi-dimensional list initialization

2012-11-05 Thread Chris Angelico
On Mon, Nov 5, 2012 at 6:54 PM, Andrew Robinson wrote: > On 11/04/2012 11:27 PM, Chris Angelico wrote: >> >> On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: >> >> x = None >> x.a = 42 >>> >>> Traceback (most recent call last): >>>File "", line 1, in >>> AttributeError: 'NoneTy