I think
grep returns true if it finds what it's looking for no?
If that's the case you can do something like:
if grep <header>
do something
else
...
Type: Posts; User: mo.reina; Keyword(s):
I think
grep returns true if it finds what it's looking for no?
If that's the case you can do something like:
if grep <header>
do something
else
...
Common Lisp, previously I used to code in Python and learned C at school. The CL community is incredibly helpful and approachable, as well as being great hackers.
Has anyone used Code Reading to learn how to read code in non C-like languages?
I'm considering buying the book but as I code mainly in Common Lisp I'm not quite sure if it will apply, I know the...
Super late to the party but...
Common Lisp:
(defun list-switch (a b lst)
"Switch elements at position a & b with each other"
(let ((newlst (copy-list lst)))
(psetf (nth a newlst)...
Tony Flury, I updated it to include a smaller example under the Data and Pipelines heading.
Please let me know if it explains the concept in a clearer manner.
Looking for criticisms and suggestions for this piece I wrote.
mozartreina.com
Does anyone have any experience with either/both hunchentoot and allegroserver? I've started dabbling into allegroserver but have just recenty heard of hunchentoot and would like to have some...
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/351159
was this issue ever resolved? i have a box running chakra linux and i've come across the same problem, was it a kernel (running 3.1)...
rig: macbook air 4,2
4 gb RAM
1.7 ghz i5 dual-core intel core
mac os lion
guest: ubuntu 11.10
2 gb RAM
guest additions
SATA hd
all done.
common lisp has remove-if-not,
my own implementation
(defun filter (fn lst)
(cond ((null (car lst)) nil)
(t (cons (if (funcall fn (car lst))
(car lst))
...
put up the revised edition
>>> main()
input task title and date:foo due tomorrow
foo due 2010-12-08
>>> main()
input task title and date:fue due day after tomorrow
fue due 2010-12-09
>>>...
in python:
import glob
import os
filelist = glob.glob('*')
for f in filelist:
newname = f[:3] + f[8:]
os.rename(f, newname)
what are you trying to do? extract whatever is between the tags?
ok this is a bit of a hack, it's not pretty and i'm not proud of it...
print len(re.findall(r'(\n1\n2\n3\n|^1\n2\n3\n)', a))
so there are two patterns being matched, either there's a new...
i'm no regex expert, but try changing the last line to this:
print len(re.findall(r'(?<!1)(1\n2\n3\n)', a))
that's a negative look behind assertion, so it should match as long as the letter...
in python
import re
def run():
with open('file.txt') as f:
a = f.read()
print len(re.findall(r'.*(1\n2\n3\n).*', a))
you have to replace string with whatever variable you're using for your text. in your case, since you've assigned the html page to text, it should be:
import urllib.request
import re
page =...
input did replace raw_input in python3.x
if you want to have a float as output, you can just change the last line to this
print((lower + upper) / 2.0)
this will print out a float. you...
regex isn't the best tool for the job. i also wrote a quick parser for my own project using regex and it wasn't a good idea.
what you can use is the string.partition method
before, tag,...
i suggest going over to the #twisted channel at freenode and asking them. they're quite helpful.
it seems to work, at least on my system.
i would re-write your script like this, to make it a bit shorter, thus easier to maintain in the future:
import os
with open('test.txt') as f:
...
thanks, that makes it much easier to read.
revised edition..
'''convert received date from stdin to datetime object with the following format, DD-month_abbreviation-YYYY
ex. 2000 12 november -> 12 Nov 2000'''
import datetime
import re...
>>> s = 'hello byte string'
>>> u = unicode(s)
>>> u
u'hello byte string'
>>> u.encode()
'hello byte string'
>>>