On 2015-04-24 09:00, Ian Kelly wrote:
> It is not equivalent to:
>
> if ("AND" in str1) or ("OR" in str1) or ("NOT" in str1):
Which python allows you to write nicely as
if any(term in str1 for term in ["AND", "OR", "NOT"]):
The use of any()/all() has certainly improved the readability of
On 2015-04-29 14:22, Emile van Sebille wrote:
> On 4/29/2015 1:49 PM, Kashif Rana wrote:
> > pol_elements =
> > re.compile('id\s(?P.+?)(?:\sname\s(?P.+?))?\sfrom\s(?P.+?)\sto\s(?P.+?)\s{2}(?P[^\s]+?)\s(?P[^\s]+?)\s(?P[^\s]+?)(?:(?P\snat)\s(?P[^\s]+?)(?P\sdip-id\s[^\s]+?)?)?\s(?P[^\s]+?)(?:\sschedul
On 2015-04-30 22:18, Cecil Westerhof wrote:
> Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel:
>> ulimit is your friend if you've got a program that wants to gobble
>> up all of swap space.
>
> Yes, my system is openSUSE 64 bit. I really should look into ulimit.
> The default is:
[snip]
>
[dangit, had Control down when I hit and it sent prematurely]
On 2015-05-02 13:02, vasudevram wrote:
> http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html
>
> https://docs.python.org/2/reference/datamodel.html
>
> and saw this excerpt:
>
> [ CPython implementation detail:
On 2015-05-02 13:02, vasudevram wrote:
> Hi group,
>
> Please refer to this blog post about code showing that a Python
> data structure can be self-referential:
>
> http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html
>
> Gotten a couple of comments on it already, but inter
On 2015-05-02 23:06, Cecil Westerhof wrote:
> Op Saturday 2 May 2015 22:17 CEST schreef Tim Chase:
>> This creates a cycle, then makes it unreachable, but the list is
>> still referenced by itself, so the reference count never drops to
>> zero (where it would get GC'd),
On 2015-05-04 21:57, Andrew Cooper wrote:
> On 04/05/2015 18:43, Ian Kelly wrote:
> >
> > Some other gotchas that aren't necessarily related to C/Java but
> > can be surprising nonetheless:
> >
> > *() is a zero-element tuple, and (a, b) is a two-element
> > tuple, but (a) is not a one-elemen
On 2015-05-05 10:09, Kashif Rana wrote:
> When I am writing list of dictionaries to CSV file, the key
> 'schedule' has value 'Mar 2012' becomes Mar-12.
How are you making this determination? Are you looking at the raw
CSV output, or are you looking at the CSV file loaded into a
spreadsheet like
On 2015-05-06 19:08, MRAB wrote:
> You could tell it to quote any value that's not a number:
>
> w = csv.DictWriter(f, pol_keys,
> quoting=csv.QUOTE_NONNUMERIC)
>
> It looks like all of the values you have are strings, so they'll
> all be quoted.
>
> I would hope that Excel will then treat
On 2015-05-06 12:27, Ian Kelly wrote:
> On Wed, May 6, 2015 at 12:22 PM, Tim Chase
> wrote:
> > On 2015-05-06 19:08, MRAB wrote:
> >> You could tell it to quote any value that's not a number:
> >>
> >> w = csv.DictWriter(f, pol_keys,
> >
On 2015-05-06 23:31, Denis McMahon wrote:
> On Tue, 05 May 2015 22:32:28 -0700, Kashif Rana wrote:
> > thanks for the feedback. I think its problem with excel itself,
> > showing wrong value. Because when I opened the csv file in text
> > editor, I can see correct value but opening in excel showing
On 2015-05-06 20:22, Tim Chase wrote:
> As ChrisA posted earlier, you have to use Excel's Import
> functionality (there are several ways to get this wizard, but not
> all ways of opening a .csv trigger the wizard), then specify those
> particular columns as "Text" rathe
On 2015-05-13 06:07, Chris Angelico wrote:
> On Wed, May 13, 2015 at 5:54 AM, Ian Kelly
> wrote:
> > Also, I like to put command-line parsing inside the main function
> > and make that its *only* responsibility. The main function then
> > calls the real entry point of my script, which will be some
On 2015-05-14 09:57, 20/20 Lab wrote:
> On 05/13/2015 06:23 PM, Steven D'Aprano wrote:
>>> I have a LARGE csv file that I need to process. 110+ columns,
>>> 72k rows. I managed to write enough to reduce it to a few
>>> hundred rows, and the five columns I'm interested in.
> I actually stumbled ac
On 2015-05-16 12:20, C.D. Reimer wrote:
> Does python perform the dot operators from left to right or
> according to a rule of order (i.e., multiplication/division before
> add/subtract)?
Yes, Python evaluates dot-operators from left to right.
-tkc
--
https://mail.python.org/mailman/listinfo/p
On 2015-05-17 21:39, Johannes Bauer wrote:
> Hey there,
>
> so that textwrap.wrap() breks non-breaking spaces, is this a bug or
> intended behavior? For example:
>
> Python 3.4.0 (default, Apr 11 2014, 13:05:11)
> [GCC 4.8.2] on linux
>
> >>> import textwrap
> >>> for line in textwrap.wrap("foo
On 2015-05-19 06:42, massi_...@msn.com wrote:
> I succesfully wrote a regex in python in order to substitute all
> the occurences in the form $"somechars" with another string. Here
> it is:
>
> re.sub(ur"""(?u)(\$\"[^\"\\]*(?:\\.[^\"\\]*)*\")""", newstring,
> string)
The expression is a little mo
On 2015-05-20 22:58, Chris Angelico wrote:
> On Wed, May 20, 2015 at 9:44 PM, Parul Mogra
> wrote:
> > My objective is to create large amount of data files (say a
> > million *.json files), using a pre-existing template file
> > (*.json). Each file would have a unique name, possibly by
> > incorpo
On 2015-05-20 17:59, Peter Otten wrote:
> Tim Chase wrote:
> > wordlist[:] = [ # just lowercase all-alpha words
> > word
> > for word in wordlist
> > if word.isalpha() and word.islower()
> > ]
>
> Just a quick reminder: if the data is
On 2015-05-22 23:34, Marko Rauhamaa wrote:
> >>> object().x = 3
> Traceback (most recent call last):
> File "", line 1, in
> AttributeError: 'object' object has no attribute 'x'
>
> Why are object instances immutable in Python?
I've wondered this on multiple occasions, as I've wanted to just mak
On 2015-05-23 11:10, Jon Ribbens wrote:
> On 2015-05-23, Michael Torrie wrote:
> > The same can be said of CA-signed certificates.
>
> I think you are falling into the trap of believing that all things
> are either perfect or they are worthless. CAs aren't perfect, but
> neither are they worthles
On 2015-05-22 15:03, Laura Creighton wrote:
> I don't know anything about Camelot.
Am I the only one who is disappointed that nobody has claimed
"Camelot...it's only a model"? :-)
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-05-26 21:45, Mark Lawrence wrote:
>> class MyClass(object):
>> def __init__(ስ):
>> ስ.dummy = None
>
> Apart from breaking all the tools that rely on "self" being spelt
> "self" this looks like an excellent idea.
Though to be fair, they *are* broken tools if they rely on "self"
On 2015-05-28 23:50, Skybuck Flying wrote:
> A = input
> B = input
> C = output
>
> A B C:
> ---
> F F T
> F T F
> T F T
> T T T
>
> Surpisingly enough I don't think there is a casual/common operator
> for this thruth table.
>
> AND does not apply.
> OR does not apply.
> XOR does not apply.
On 2015-05-29 13:48, Chris Angelico wrote:
> That said, though, using 0 for False and 1 for True is easily
> the most common convention in use today, and the next most likely
> case is that comparing booleans would give a simple and immediate
> error. So it's most likely to be safe to do.
There ar
On 2015-05-30 10:30, Justin Thyme wrote:
> Is it possible to write a Python program that will start MS Excel,
> create a spreadsheet and fill cells A1 to A10 (say) with the data
> in a Python array? The answer is surely yes, but is there an
> outline of how to do it somewhere?
it depends on how
Is Python supposed to support POSIX "equivalence classes"? I tried
the following in Py2 and Py3:
>>> re.sub('[[=a=]]', 'A', 'aáàãâä', re.U)
'aáàãâä'
which suggests that it doesn't (I would have expected "AA" as the
result).
Is there a way to get this behavior?
I found that perl knows a
On 2015-06-02 04:37, Mark Lawrence wrote:
> > I read the online help about string. It lists string constants,
> > string formatting, template strings and string functions. After
> > reading these, I am still puzzled about how to use the string
> > module.
>
> I suggest you don't bother, it's effec
On 2015-06-04 06:36, Palpandi wrote:
> This is the case. To split "string2" from "string1_string2" I am
> using re.split('_', "string1_string2", 1)[1].
>
> It is working fine for string "string1_string2" and output as
> "string2". But actually the problem is that if a sting is
> "__string1_string2
On 2015-06-04 13:09, Michael Torrie wrote:
> Why not use Python for what it's good for and say pipe the results
> of find into your python script? Reinventing find poorly isn't
> going to buy you anything.
Until you port your app to Windows where find(1) is unavailable
natively ;-)
-tkc
--
h
str.split() doesn't seem to respect non-breaking space:
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(repr("hello\N{NO-BREAK SPACE}world".split()))
['hello', 'world']
What's the purpos
On 2015-06-21 17:08, John T. Haggerty wrote:
> I'm looking to just have a simple program that will do a SQLite
> query pull a random record and then copy that record too the
> clipboard the system. I'm not quite seeing how to do this perhaps
> this is already been done elsewhere but I spent quite a
On 2015-07-01 21:51, Peter Otten wrote:
> use a loop:
>
> CHUNKSIZE = 16*1024 # for example
> while True:
>data = response.read(CHUNKSIZE)
>if not data:
>break
>out_file.write(data)
>
>
> This can be simplified:
>
> shutil.copyfileobj(response, out_file)
It's these little
On 2015-07-03 00:52, Steven D'Aprano wrote:
> x = 1 - 1/2**53
> assert x == 0.
> for i in range(1, 100):
> if int(i*x) == i:
> print(i); break
tkc@debian:~$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credit
On 2015-07-05 15:36, Tim Chase wrote:
> On 2015-07-05 20:29, Stefan Ram wrote:
> > But why do we not have a common and well-known term for
> > the counterpart, that something does not modify the state
> > of the world, but that the state of the world does
>
On 2015-07-05 20:29, Stefan Ram wrote:
> But why do we not have a common and well-known term for
> the counterpart, that something does not modify the state
> of the world, but that the state of the world does
> influence the value (behaviour) of a call such as
> »datetime.datetime.now()
On 2015-07-06 00:44, Robert Kern wrote:
>> I believe the term is "idempotent"
>
> No, "idempotent" means that if it changes the state, then applying
> it twice or more has the same effect as applying it once.
Ah, thanks for the clarification.
-tkc
--
https://mail.python.org/mailman/listinfo/
On 2015-07-10 09:27, Mark Storkamp via Python-list wrote:
> sourcedir = os.environ['HOME']+"/Documents/"
First, I'd do a couple things here to accommodate various systems to
make it cross-platform:
sourcedir = os.path.join(
os.path.expanduser('~'),
"Documents"
)
> os.chdir(sourcedi
On 2015-07-19 14:45, Steven D'Aprano wrote:
>> ie we can now do
> १ + २
>> 3
>
> That is actually quite awesome, and I would support a new feature
> that set the numeric characters to a particular script, e.g. Latin,
> Arabic, Devanagari, whatever, and printed them in that same script.
> I
On 2015-07-20 04:07, Chris Angelico wrote:
> The int() and float() functions accept, if I'm not mistaken,
> anything with Unicode category "Nd" (Number, decimal digit). In
> your examples, the fraction (U+215B) is No, and the Roman numerals
> (U+2168, U+2182) are Nl, so they're not supported. Addin
On 2015-08-01 13:34, Lukas Barth wrote:
> I have a list of numbers that I treat as "circular", i.e. [1,2,3]
> and [2,3,1] should be the same. Now I want to rotate these to a
> well defined status, so that I can can compare them.
>
> If all elements are unique, the solution is easy: find the minimu
On 2015-08-02 21:54, Ben Finney wrote:
> So, both XML and JSON should be considered write-only, and produced
> only for consumption by a computer; they are a poor choice for
> presenting to a human.
>
> The “INI” format as handled by the Python ‘configparser’ module is
> what I would recommend for
On 2015-08-02 12:11, Cecil Westerhof wrote:
> There are a lot of ways to store configuration information:
> - conf file
> - xml file
> - database
> - json file
> - and possible a lot of other ways
>
> I want to write a Python program to display cleaned log files. I do
> not think I need a lot of c
On 2015-08-05 06:37, Rustom Mody wrote:
> > config = {}
> > with open('config.ini') as f:
> > for row in f:
> > row = row.strip()
> > if not row or row.startswith(('#', ';')):
> > continue
> > k, _, v = row.partition('=')
> > config[k.strip().upper()] = v.lst
On 2015-08-06 00:47, Marko Rauhamaa wrote:
> > There's a certain simplicity to simply having key/value pairs
> > separated by an "=" and then letting the application do whatever
> > it needs/wants with those key/value strings.
>
> That trap has lured in a lot of wildlife.
>
> What to do with li
On 2015-08-09 19:24, Chris Angelico wrote:
> That's exactly right. The only way for the interpreter to handle
> 'in' on an iterator is something like this:
>
> def contains(iter, obj):
> for val in iter:
> if val == obj: return True
> return False
Which can nicely be written as
On 2015-08-09 19:24, Chris Angelico wrote:
> That's exactly right. The only way for the interpreter to handle
> 'in' on an iterator is something like this:
>
> def contains(iter, obj):
> for val in iter:
> if val == obj: return True
> return False
Which can nicely be written as
On 2015-08-19 15:57, Anton wrote:
> Probably a silly question.
> Let's say I have a dictionary mydict and I need to test if a
> dictionary is empty.
>
> I would use
>
> if not mydict:
> """do something"""
>
> But I just came across a line of code like:
>
> if mydict == {}:
> """do some
On 2015-08-25 16:59, Jean-Michel Pichavant wrote:
> - Original Message -
> > From: "Joel Goldstick"
> > its called list unpacking or packing (?)
> >
> > the right side is considered a tuple because of the commas
> > >>> a = 1,2,3
> > >>> a
> > (1, 2, 3)
> > >>> a[1]
> > 2
>
> To add to J
On 2015-08-26 17:20, Terry Reedy wrote:
> On 8/26/2015 12:36 PM, Jean-Michel Pichavant wrote:
> Are you allowed to use a newsreader or a mail+newsreader (Outlook
> Express, Thunderbird, )? If so post through newsgroup
> gmane.comp.python.general at news.gmane.org (as I am).
Even if NNTP is block
On 2015-09-03 14:48, Peter Otten wrote:
> The only reason I see to add an extra comma are smaller and easier
> to read diffs when you make a change:
While that's the primary reason I do it, it's also helpful if you
have a bunch of named keyword arguments and want sort/rearrange them
(usually for c
On 2015-09-06 16:09, babi pepek wrote:
> I wand update
Use pip. It's like a magic wand.
http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-09-16 10:03, Random832 wrote:
> Do chained "in" comparisons ever really make sense, even when
> they're all the same type?
>
> I mean, I suppose 1 in (1, 2) in ((1, 2), (3, 4)) is technically
> true, but how useful is it really?
I could concoct a "useful" example where "in" is involved in
On 2015-09-16 21:25, Mark Lawrence wrote:
> Is it:-
>
> modern art == crap
>
> or
>
> modern art = crap
Pretty sure they're both wrong...
modern art < crap
;-)
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-09-17 22:46, Sven R. Kunze wrote:
> >> Btw. ASCII art is also art. So, why does Python not have ASCII
> >> art to define graphs and diagrams?
> >
> > Nowadays it would have to support Unicode art. Mustn't
> > leave out all the world's non-English-speaking artists!
>
> How do I debug and mo
On 2015-09-29 21:32, Mark Lawrence wrote:
> On 29/09/2015 17:48, Rob Gaddi wrote:
> >> Is there any similar elegant way to check if a value is out of
> >> certain range?
> >> Example - To check if x is either less than zero or greater than
> >> ten? Right now I am using x < 0 or x > 10.
> >
> > not
On 2015-09-30 11:34, massi_...@msn.com wrote:
> firstly the description of my problem. I have a string in the
> following form:
>
> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>
> that is a string made up of groups in the form 'name' (letters
> only) plus possibly a tuple containing 1 or
On 2015-10-01 01:48, gal kauffman wrote:
> items = s.replace(' (', '(').replace(', ',',').split()
s = "name1 (1)"
Your suggestion doesn't catch cases where more than one space can
occur before the paren.
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-10-06 00:51, Chris Angelico wrote:
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> # all the same down to here
> blanks = set(rdr.fieldnames)
> for row in rdr:
> blanks = {col for col in blanks if not row[col]}
> mt = [col for col in rdr.fieldnames
On 2015-10-09 14:01, Grant Edwards wrote:
> > Is there an available script to remove file created by either
> > using the Python module or by using git?
>
> Yes. Execute the following at the bash prompt:
>
> $ rm $(find . )
If you've got GNU find, you can just
$ find . -type f {find-options-
On 2015-10-27 17:24, Ganesh Pal wrote:
> from myPopen import run
>
> def configure_network():
> """
> Prepare network for test
> """
> try:
> cmd = ("netadm enable -p ncp DefaultFixed")
> out, err, ret = run(cmd, timeout=60)
> if ret != "":
> log
On 2015-10-29 09:38, Chris Angelico wrote:
> On Thu, Oct 29, 2015 at 9:30 AM, Marc Aymerich
> wrote:
> > I'm writting an application that saves historical state in a log
> > file. I want to be really efficient in terms of used bytes.
>
> Why, exactly?
>
> By zipping the state, you make it utterl
On 2015-10-29 00:21, Mark Lawrence wrote:
> On 28/10/2015 22:53, Tim Chase wrote:
>> If nobody is monitoring the logs, just write them to /dev/null
>> for 100% compression. ;-)
>
> Can you get better than 100% compression if you write them to
> somewhere other than /dev/
On 2015-11-02 20:09, Seymore4Head wrote:
> How do I make a regular expression that returns true if the end of
> the line is an asterisk
Why use a regular expression?
if line[-1] == '*':
yep(line)
else:
nope(line)
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-11-03 10:25, Peter Otten wrote:
> >>> How do I make a regular expression that returns true if the end
> >>> of the line is an asterisk
> >>
> >> Why use a regular expression?
> >>
> >> if line[-1] == '*':
> >> yep(line)
> >> else:
> >> nope(line)
>
> Incidentally the code exa
On 2015-11-02 22:17, Seymore4Head wrote:
> On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase
> wrote:
>
> >On 2015-11-02 20:09, Seymore4Head wrote:
> >> How do I make a regular expression that returns true if the end
> >> of the line is an asterisk
> >
> &g
On 2015-11-03 16:35, Peter Otten wrote:
> I wish there were a way to prohibit such files. Maybe a special
> value
>
> with open(..., newline="normalize") f:
> assert all(line.endswith("\n") for line in f)
>
> to ensure that all lines end with "\n"?
Or even more valuable to me:
with open(
On 2015-11-03 11:39, Ian Kelly wrote:
> >> because I have countless loops that look something like
> >>
> >> with open(...) as f:
> >> for line in f:
> >> line = line.rstrip('\r\n')
> >> process(line)
> >
> > What would happen if you read a file opened like this without
> > iter
On 2015-11-03 19:04, Michael Torrie wrote:
> Grep can use regular expressions (and I do so with it regularly),
> but it's default mode is certainly not regular expressions, and it
> is still very powerful.
I suspect you're thinking of `fgrep` (AKA "grep -F") which uses fixed
strings rather than re
On 2015-11-04 14:39, Steven D'Aprano wrote:
> On Wednesday 04 November 2015 03:56, Tim Chase wrote:
>> Or even more valuable to me:
>>
>> with open(..., newline="strip") as f:
>> assert all(not line.endswith(("\n", "\r")) for l
On 2015-11-04 09:57, Peter Otten wrote:
> Well, I didn't know that grep uses regular expressions by default.
It doesn't help that grep(1) comes in multiple flavors:
grep: should use BRE (Basic REs)
fgrep: same as "grep -F"; uses fixed strings, no REs
egrep: same as "grep -E"; uses ERE (Extende
On 2015-11-05 05:24, Ben Finney wrote:
> A very common command to issue, then, is “actually show me the line
> of text I just specified”; the ‘p’ (for “print”) command.
>
> Another very common command is “find the text matching this pattern
> and perform these commands on it”, which is ‘g’ (for “g
On 2015-11-05 13:28, Steven D'Aprano wrote:
> > I tried Tim's example
> >
> > $ seq 5 | grep '1*'
> > 1
> > 2
> > 3
> > 4
> > 5
> > $
>
> I don't understand this. What on earth is grep matching? How does
> "4" match "1*"?
The line with "4" matches "zero or more 1s". If it was searching for
a
On 2015-11-05 23:05, Steven D'Aprano wrote:
> Oh the shame, I knew that. Somehow I tangled myself in a knot,
> thinking that it had to be 1 *followed by* zero or more characters.
> But of course it's not a glob, it's a regex.
But that's a good reminder of fnmatch/glob modules too. Sometimes
all y
On 2015-11-09 08:12, zljubi...@gmail.com wrote:
> I know how to send an email, but I would like to be able to receive
> a reply and act accordingly. Mail reply should contain yes/no
> answer.
You have a couple options that occur to me:
1) set up an SMTP server somewhere (or use the existing one y
On 2015-11-09 13:53, zljubi...@gmail.com wrote:
> > You have a couple options that occur to me:
> >
> > 1) set up an SMTP server somewhere (or use the existing one you're
> > receiving this email at in the event you're getting it as mail
> > rather than reading it via NNTP or a web interface) to r
On 2015-11-11 08:34, Anas Belemlih wrote:
> i am a beginning programmer, i am trying to write a simple code
> to compare two character sets in 2 seperate files. ( 2 hash value
> files basically) idea is: open both files, measure the length of
> the loop on.
>
> if the length doesn't match, ==
On 2015-11-12 08:21, Marko Rauhamaa wrote:
> And if you really wanted to compare two files that are known to
> contain MD5 checksums, the simplest way is:
>
>with open('f1.md5') as f1, open('f2.md5') as f2:
>if f1.read() == f2.read():
>...
>else:
>...
T
On 2015-11-12 15:56, Peter Otten wrote:
> Tim Chase wrote:
>
> > with open("file1.md5") as a, open("file2.md5") as b:
> > for s1, s2 in zip(a, b):
> > if s1 != s2:
> > print("Files differ")
>
> Note that this w
On 2015-11-12 07:47, John Zhao wrote:
> I have a configuration file with repeating sections, for example,
>
> [INSTANCE]
> Name=a
>
> [INSTANCE]
> Name=b
>
> I hope I can use ConfigParser to read the file and store the
> configuration settings in arrays.
>
> Is that possible?
Not with the s
On 2015-11-15 12:38, jbak36 wrote:
> Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC
> v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or
> "license()" for more information.
> >>> #this program says hello and asks for my name
> >>> print:('Hello world!')
> Hello world!
W
On 2015-11-15 16:27, fl wrote:
> When I learn slice, I have a new question on the help file. If I
> set:
>
> pp=a[0:10:2]
>
> pp is array([1, 3])
>
> I don't know how a[0:10:2] gives array([1, 3]).
>
> I know matlab a lot, but here it seems quite different. Could you
> tell me what meaning a[0:
On 2014-06-06 10:47, Johannes Bauer wrote:
> > Personally I tend toward rstrip('\r\n') so that I don't have to
> > worry about files with alternative line terminators.
>
> Hm, I was under the impression that Python already took care of
> removing the \r at a line ending. Checking that right now:
>
On 2014-06-06 09:59, Travis Griggs wrote:
> On Jun 4, 2014, at 4:01 AM, Tim Chase wrote:
> > If you use UTF-8 for everything
>
> It seems to me, that increasingly other libraries (C, etc), use
> utf8 as the preferred string interchange format.
I definitely advocate UTF-8
On 2014-06-16 20:41, Chris Angelico wrote:
> Oops! I made the cardinal error of trying in one and assuming it'd
> work in both. Just needs a b prefix on the split string:
>
> def shell_split(cmd):
> return subprocess.check_output("""python -c 'import sys;
> print("\\0".join(sys.argv[1:]))'
> "
On 2014-06-16 13:51, Antoon Pardon wrote:
> >>> shlex.split("ls *.py")
> ['ls', '*.py']
> >>> shlex.split("ls '*.py'")
> ['ls', '*.py']
To accommodate this, I'd probably just clone the shlib.py to my local
project under a new name and then tweak the source to emit whether a
token was quoted or
> Any evidence out there that this part of PEP8 is becoming
> more optional or even obsolete, as I've heard others
> say about the 80 char line length?
>
> Just need ammo for when the hammer of code
> unification comes down.
I'm not sure you'll get a whole lot of "PEP8 is optional or
obsolete", t
On 2014-07-03 19:02, Grant Edwards wrote:
> > That may be true, but that same person is going to have a
> > difficult time editing the code.
>
> That's true with Notepad, but with dozens of other programming
> editors, code indented with spaces will read and edit prefectly.
> Not so for tab-inde
On 2014-07-05 11:17, Gregory Ewing wrote:
> > PEP8 suggests using this style of method invocation:
> >
> > obj.method(foo,
> >bar,
> >baz)
> >
> > which is an effect impossible to do correctly with tabs alone.
>
> Yes, PEP 8 is self-contradictory in that reg
On 2014-07-06 05:13, rxjw...@gmail.com wrote:
> What I get on Python console:
>
> $ python
> Python 2.7.5 (default, Oct 2 2013, 22:34:09)
> [GCC 4.8.1] on cygwin
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> import re
> >>> p = re.compile('ab*')
> File "", lin
On 2014-07-06 17:52, Steven D'Aprano wrote:
> I have a monkey-patched version of dir() which takes a second
> argument, a glob, to filter the list of names returned:
>
> py> len(dir(os)) # Too much!
> 312
> py> dir(os, 'env')
> ['_putenv', '_unsetenv', 'environ', 'environb', 'getenv',
> 'getenvb'
On 2014-07-08 11:08, Terry Reedy wrote:
> > Indeed. Ctrl-D is _the_ canonical way to tell a program that's
> > reading stdin that your're done.
>
> Not on Windows.
Okay, EOF is the canonical way to tell a program reading stdin that
you're done. It just happens that EOF ^D on *nix-likes and ^Z
On 2014-07-09 01:24, Chris Angelico wrote:
> On Wed, Jul 9, 2014 at 1:20 AM, Tim Chase
> > Okay, EOF is the canonical way to tell a program reading stdin
> > that you're done. It just happens that EOF ^D on *nix-likes and
> > ^Z on Win32. :-)
> >
> > -tkc
&g
On 2014-07-09 01:49, Chris Angelico wrote:
> Have you ever used COPY CON to create a binary file?
No, for that I used DEBUG.EXE (or DEBUG.COM on older versions of DOS)
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
On 2014-07-09 01:24, Chris Angelico wrote:
> I can't think of any Windows-native programs that ask for EOF. Only
> those which came from POSIX platforms do it. That said, though,
> Windows doesn't tend to encourage interactive command-line programs
> at all, so you may as well just follow the Unix
On 2014-07-09 12:48, Steven D'Aprano wrote:
> On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote:
>
> > We would have *three* ways to compare for equality (==, ===, and
> > is).
>
> `is` does not, never has, and never will, be a test for equality.
>
> py> x = []
> py> y = []
> py> x is y
> Fals
On 2014-07-10 22:18, Roy Smith wrote:
> > Outside this are \( and \): these are literal opening and closing
> > bracket characters. So:
> >
> >\(\([^)]+\)\)
>
> although, even better would be to use to utterly awesome
>> re.VERBOSE
> flag, and write it as:
>
> \({2} [^)]+ \){2}
Or heck
On 2014-07-20 23:40, Irmen de Jong wrote:
> > And since IDLE is not a "tabbed editor", only *1* document
> > is going to be displayed at a time.
>
> False. Idle opens any number of documents at the same time just
> fine (in different windows - rather than tabs).
This sounds like a failing of th
On 2014-07-20 23:40, Irmen de Jong wrote:
> > And since IDLE is not a "tabbed editor", only *1* document
> > is going to be displayed at a time.
>
> False. Idle opens any number of documents at the same time just
> fine (in different windows - rather than tabs).
This sounds like a failing of th
On 2014-07-20 19:06, Rick Johnson wrote:
>
> STEPS TO REPRODUCE BUG 1: "Attack of the clones!"
>
>
> 1. Open the IDLE application
> 2. Maximize the window that appears
> 3. Go
901 - 1000 of 2407 matches
Mail list logo