Re: How to check the date validity?

2013-12-23 Thread Andreas Perstinger
Jason Friedman wrote: >Would this not work? >import re >if re.search(r"\d{1,2}:\d{2}:\d{2}(.\d{1,3})?", "12:55:55.705"): ># It's a time No, because this regexp also matches stuff like "99:99:99.999". Checking for the number of digits is not enough, because not all combinations of two digits a

Re: Datetime string reformatting

2013-12-22 Thread Andreas Perstinger
On 22.12.2013 11:58, Igor Korot wrote: My script receives a data from the csv file. In this csv file there is a datetime field. This datetime field is formatted as follows: %m/%d/%Y %H:%M:%S.{milliseconds}. I'm reading this field into the string with this format. The trouble comes from the fact

Re: PDFMiner install question

2013-12-20 Thread Andreas Perstinger
Jason Mellone wrote: >I get the following error: >PS C:\USERS\Python27> .\python.exe .\MyTest.py >Traceback (most recent call last): > File ".\MyTest.py", line 4, in >from pdfminer.pdfpage import PDFTextExtractionNotAllowed >ImportError: cannot import name PDFTextExtractionNotAllowed > > >If

Re: Need Help with the BeautifulSoup problem, please

2013-12-16 Thread Andreas Perstinger
On 16.12.2013 07:41, seasp...@gmail.com wrote: I need to replace all tag with after ■. But the result frombelow is '■ D / ' Can you explain what I did wrong, please. s = '■A B C D / ' soup = BeautifulSoup(s) for i in soup.find_all(text='■'): tag = soup.new_tag('span')

Re: problem with graph of python(show)

2013-12-10 Thread Andreas Perstinger
On 10.12.2013 18:03, Asemaneh Allame wrote: my mean is obvios i cont get any graph of vpython it shows me a maseage in this form: " pythonw.exe has stopped working" i m sure that have a good & perfect install and i dont khnow what s problem is that enouph?? No, that's not enough. You need t

Re: using ffmpeg command line with python's subprocess module

2013-12-10 Thread Andreas Perstinger
iMath wrote: >we don't have permission to use the temporary file while it has not >been closed,but when the file is closed , it will be destroyed by >default(delete=True),but once we set delete=False,then we couldn't >depend on the convenience of letting the temporary file automatically >delete it

Re: using ffmpeg command line with python's subprocess module

2013-12-04 Thread Andreas Perstinger
iMath wrote: >I use the following code to do the test ,but error occurred ,it >prompts system cannot find specified files ,but the files are indeed >exists there ,any help ? > >with tempfile.TemporaryFile() as fp: >fp.write(("file '"+'a1.mp3'+"'\n").encode('utf-8')) >fp.write(("file '"+'a2

Re: Question regarding 2 modules installed via 'pip'

2013-11-16 Thread Andreas Perstinger
On 16.11.2013 16:13, Ferrous Cranus wrote: Τη Σάββατο, 16 Νοεμβρίου 2013 5:01:15 μ.μ. UTC+2, ο χρήστης Robert Kern έγραψε: The kind people at http://serverfault.com/ can help you with your system administration problems. I'm afraid that we cannot. Robert i have followed your advise and akse th

Re: How to add a current string into an already existing list

2013-11-02 Thread Andreas Perstinger
On 02.11.2013 12:58, Nick the Gr33k wrote: Trying to add the current filename into the existent 'downloads' column Somehow i don't think i just use the plus sign into an existing column. We don't try to add numbers here but add an extra string to an already existing array of strings(list). [SNI

Re: How to get final URL after redirection

2013-10-31 Thread Andreas Perstinger
nishant bhakta wrote: >I have a link that will redirect to any-other link and i have to work >with that final link. For example if i have a link "www.bit.ly/2V6CFi" >that will redirect to "www.google.com". Here i want that i take >"www.bit.ly/2V6CFi" and find the final redirect link and append >"

Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 17:25, Antoon Pardon wrote: Op 08-10-13 16:24, Andreas Perstinger schreef: Looking at the docs, I've found there is also "message_from_binary_file" which works for me with your code. http://docs.python.org/3/library/email.parser.html#email.message_from_binary_file

Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 14:20, Antoon Pardon wrote: As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a debian box I have the following code. #!/usr/bin/python3 import sys from email import message_from_file sys.stdi

Re: Re for Apache log file format

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 08:33, Sam Giraffe wrote: #this is a single line string = '192.168.122.3 - - [29/Sep/2013:03:52:33 -0700] "GET / HTTP/1.0" 302 276 "-" "check_http/v1.4.16 (nagios-plugins 1.4.16)"' #trying to break up the pattern match for easy to read code pattern = re.compile(r'(?P\d{1,3}\.\d{1,3

Re: How to streamingly read text file and display whenever updated text

2013-10-07 Thread Andreas Perstinger
On 07.10.2013 03:54, galeom...@gmail.com wrote: https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing For the readers who don't bother clicking on the link above: It's a short video where the OP demonstrates how her/his usage of tail doesn't work. no matter call tai

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> print(cookie1) Set-Cookie: ID="Set-Cookie: ID=42" >>> cookie1.

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 17:31, Νίκος Αλεξόπουλος wrote: Now i have it like this: # connect to database con = pymysql.connect( db = 'nikos_metrites', user = 'nikos_root', passwd = 't1abhp2r!', charset = 'utf8', host = 'localhost' ) Just to be sure: That's not your real password, is it? Bye, Andreas --

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Andreas Perstinger
Νίκος wrote: >Στις 28/9/2013 1:19 μμ, ο/η Chris Angelico έγραψε: >> [ROLL] Rosuav rolls his eyes: 1, 1, totalling 2. >> >> Then split your try blocks! You've already been told this. >> >No we didn't have said this. if you are referring to this: At least Denis told you about 24 hours ago: https:/

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Andreas Perstinger
On 28.09.2013 08:26, Daniel Stojanov wrote: Can somebody explain this. The line number reported by shlex depends on the previous token. I want to be able to tell if I have just popped the last token on a line. [SNIP] second = shlex.shlex("word1 word2,\nword3") Punctuation characters like th

Re: print function and unwanted trailing space

2013-08-31 Thread Andreas Perstinger
On 31.08.2013 10:17, candide wrote: What is the equivalent in Python 3 to the following Python 2 code: # - for i in range(5): print i, # - ? How about >>> print(" ".join(str(i) for i in range(5))) 0 1 2 3 4 Bye, Andreas -- ht

Re: Question about mailing list rules

2013-07-12 Thread Andreas Perstinger
On 12.07.2013 01:59, Devyn Collier Johnson wrote: Am I allowed to ask questions like "Here is my code. How can I optimize it?" on this mailing list? If it's written in Python, why not? But that doesn't mean you are guaranteed to get an answer :-). And please read http://sscce.org/ before post

Re: A few questiosn about encoding

2013-06-20 Thread Andreas Perstinger
Rick Johnson wrote: > > Since we're on the subject of Unicode: > >One the most humorous aspects of Unicode is that it has >encodings for Braille characters. Hmm, this presents a

Re: Help me with the script? How to find items in csv file A and not in file B and vice versa

2013-06-18 Thread Andreas Perstinger
alonn...@gmail.com wrote: >and when I run it I get an invalid syntex error and (as a true newbie >I used a GUI)in_a_not_b is highlighted in the with open("inAnotB.csv", >"wb") as f: >writer = csv.writer(f) >writer.writerows([item] for item in_a_not_b)

Re: OT: C vs Python terminology

2013-06-16 Thread Andreas Perstinger
On 16.06.2013 14:55, Dave Angel wrote: On 06/16/2013 07:22 AM, Andreas Perstinger wrote: On 16.06.2013 08:32, Denis McMahon wrote: C: ^ int a, b; b = 6; a = b; In C, this places the numeric value 6 into the memory location identified ^ by the variable "b"

OT: C vs Python terminology (was: A certainl part of an if() structure never gets executed)

2013-06-16 Thread Andreas Perstinger
On 16.06.2013 08:32, Denis McMahon wrote: C: int a, b; b = 6; a = b; In C, this places the numeric value 6 into the memory location identified by the variable "b", so far so good. then copies the value from the location pointed to by "b" into the location pointed to by "a". Wrong. Neither

Re: Don't feed the troll...

2013-06-15 Thread Andreas Perstinger
Nick the Gr33k wrote: >You are spamming my thread. Well, you don't own this thread. In fact nobody owns it. This is a public forum and thus anybody can answer to any post as he likes. Bye, Andreas -- http://mail.python.org/mailman/listinfo/python-list

Re: Pattern Search Regular Expression

2013-06-15 Thread Andreas Perstinger
subhabangal...@gmail.com wrote: >I know this solution but I want to have Regular Expression option. >Just learning. http://mattgemmell.com/2008/12/08/what-have-you-tried/ Just spell out what you want: A word at the beginning, followed by any text, followed by a word at the end. Now look up the ba

Re: Having a hard time to 'get' bing api search results

2013-06-14 Thread Andreas Perstinger
On 14.06.2013 20:19, Yves S. Garret wrote: This is the error that I'm getting right now. import json from pprint import pprint path = '/home/azureuser/temp.json' with open(path) as data_file: ... data = json.load(data_file) ... Traceback (most recent call last): File "", line 2, in Fil

Re: Having a hard time to 'get' bing api search results

2013-06-13 Thread Andreas Perstinger
On 14.06.2013 03:00, Yves S. Garret wrote: Thanks again Kevin. I'm deviating from the original thread, but I've got another issue. When I try to load the json file and then parse it, this is the error that I get: http://bin.cakephp.org/view/1329549559 1) Please don't top post. Put your answer

Re: Wrong website loaded when other requested

2013-06-13 Thread Andreas Perstinger
On 13.06.2013 20:10, Nick the Gr33k wrote: [nothing new] Could you please stop spamming the whole internet with your problems. Not only that you've posted two similar offtopic messages within only 6 minutes to this list, you've also crossposted to alt.os.linux (where it is offtopic too) and to

Re: Wrong website loaded when other requested

2013-06-13 Thread Andreas Perstinger
On 13.06.2013 16:23, Νικόλαος Κούρας wrote: Please suggest something of why this happnes. That's not a Python problem. BTW both scripts at http://superhost.gr/~dauwin/metrites.py and at http://superhost.gr/~dauwin/cgi-bin/metrites.py show the world the passwords to your databases in plain text

Re: Problem creating a regular expression to parse open-iscsi, iscsiadm output (help?)

2013-06-13 Thread Andreas Perstinger
On 13.06.2013 02:59, rice.cr...@gmail.com wrote: I am parsing the output of an open-iscsi command that contains severalblocks of data for each data set. Each block has the format: [SNIP] I tried using \s* to swallow the whitespace between the to iSCSI lines. No joy... However [\s\S]*? allows th

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Andreas Perstinger
[Please trim your replies to the relevant parts.] On 12.06.2013 10:54, Νικόλαος Κούρας wrote: But when it comes to select '==' from month instead of '==' to be submitted a zero gets submitted and i think the problem is the way i'm filling up months into the drop down menu which i

Re: OT: e-mail reply to old/archived message

2013-06-11 Thread Andreas Perstinger
On 11.06.2013 22:14, Νικόλαος Κούρας wrote: Τη Τρίτη, 11 Ιουνίου 2013 2:21:50 μ.μ. UTC+3, ο χρήστης Andreas Perstinger έγραψε: > sending the mail to python-list@python.org will just open anew > subject intead of replyign to an opened thread. You would need to find out the Message-Id

Re: Receing a form variable as a list instead of as a string

2013-06-11 Thread Andreas Perstinger
On 11.06.2013 12:38, Νικόλαος Κούρας wrote: but page is a form variable coming from a previous sumbitted form why the error says 'page' is a list? RTFM: "If the submitted form data contains more than one field with the same name, the object retrieved by form[key] is not a FieldStorage or Mini

OT: e-mail reply to old/archived message (was Re: Encoding questions (continuation))

2013-06-11 Thread Andreas Perstinger
On 10.06.2013 15:56, Νικόλαος Κούρας wrote: Τη Δευτέρα, 10 Ιουνίου 2013 2:41:07 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: On Mon, 10 Jun 2013 14:13:00 +0300, Νικόλαος Κούρας wrote: ps. i tried to post a reply to the thread i opend via thunderbird mail client, but not as a reply to somne oth

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-10 Thread Andreas Perstinger
On 10.06.2013 11:59, Νικόλαος Κούρας wrote: s = 'α' s.encode('utf-8') > b'\xce\xb1' 'b' stands for binary right? No, here it stands for bytes: http://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals b'\xce\xb1' = we are looking at a byte in a hexadecim

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-10 Thread Andreas Perstinger
On 10.06.2013 09:10, nagia.rets...@gmail.com wrote: Τη Κυριακή, 9 Ιουνίου 2013 3:31:44 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: py> c = 'α' py> ord(c) 945 The number 945 is the characters 'α' ordinal value in the unicode charset correct? Yes, the unicode character set is just a big li

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-09 Thread Andreas Perstinger
On 09.06.2013 11:38, Νικόλαος Κούρας wrote: s = 'α' s = s.encode('iso-8859-7').decode('utf-8') print( s ) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 0: unexpected end of data Why this error? because 'a' ordinal value > 127 ? >>> s = 'α' >>> s.encode('iso-8859-7') b'

Re: Source code as text/plain

2013-06-04 Thread Andreas Perstinger
On 04.06.2013 00:34, Carlos Nepomuceno wrote: Date: Mon, 3 Jun 2013 09:06:46 +1000 From: c...@zip.com.au To: c...@rebertia.com [...] http://hg.python.org/cpython/raw-file/tip/Lib/string.py What's the 'tip' tag? htt

Re: netcdF4 variables

2013-06-01 Thread Andreas Perstinger
On 01.06.2013 05:30, Sudheer Joseph wrote: some hing like a list xx=nc,variables[:] should get me all variable names with out other surrounding stuff?? In [4]: ncf.variables Out[4]: OrderedDict([(u'LON', ), [SNIP] It looks like "variables" is an OrderedDict. Thus >>> ncf.variables.keys() sho

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-24 Thread Andreas Perstinger
On 24.05.2013 17:25, Carlos Nepomuceno wrote: Date: Thu, 23 May 2013 19:29:14 -0700 Subject: Re: PEP 378: Format Specifier for Thousands Separator From: dihedral88...@gmail.com [some typical dihedral stuff] I'm sorry but I don't understand your question

Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Andreas Perstinger
On 14.05.2013 21:00, krishna2pra...@gmail.com wrote: # first, open the file as a plain binary try: self.file = open(/dev/relpcfpga, "r+b", buffering=0) Aren't you missing the quotes for "/dev/relpcfpga"? The method seek() complains "OSError: [Errno 29] Illegal seek" The device relpc

Re: global variable not working inside function. Increment

2013-05-13 Thread Andreas Perstinger
"feather.duster.kung.fu" wrote: >I'm just learning Python and NONE of the tutorials I read said >anything about that . In fact they all say a global can be called from >inside a Function. If possible please contact the ppl that write these >things. Well, we don't know which tutorials you read. So

Re: Error in "Import gv " module

2013-04-22 Thread Andreas Perstinger
You are still top posting. On 22.04.2013 14:43, Megha Agrawal wrote: yes, I did. They said, gv module doesn't exist for windows. Then I'm afraid you are out of luck. Two possible alternatives: 1) Save your graph to a file and use the command line tools: http://stackoverflow.com/a/12698636 2

Re: Error in "Import gv " module

2013-04-22 Thread Andreas Perstinger
Please avoid top posting and answer to the list. On 22.04.2013 12:38, Megha Agrawal wrote: Widows 7, and i have pygraphviz library in python27-> lib-> site-package folder. Sorry don't know much about Windows. Have you read through all the issues involving "import gv" errors?: https://code.goo

Re: Error in "Import gv " module

2013-04-22 Thread Andreas Perstinger
On 22.04.2013 12:13, Megha Agrawal wrote: https://code.google.com/p/python-graph/wiki/Example When I am trying to run the code to draw a graph, given on above link, I am getting following error: ImportError: No module named gv What can be the reasons? Which OS? It looks like you are missing

Re: Simple Plot in Python

2013-03-16 Thread Andreas Perstinger
subhabangal...@gmail.com wrote: >I was trying to draw in Matplotlib but did not find much help. Have you looked already at the homepape for "maptlotlib"?: http://matplotlib.org/index.html There you'll find a tutorial: http://matplotlib.org/users/pyplot_tutorial.html Bye, Andreas -- http://mail.

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Andreas Perstinger
Lele Gaifax wrote: >Ferrous Cranus writes: > >> Let me ask it like this: >> How can i avoid using try: except: for checkign the date but instead >> check it with an if statement: > >Let me answer this way: you can't, without resorting to the simple >helper functions I wrote in my previous message

Re: How to tell people to ask questions the smart way

2012-09-05 Thread Andreas Perstinger
On 05.09.2012 01:05, Ben Finney wrote: Andreas Perstinger writes: On 04.09.2012 11:34, Paolo wrote: > how do I know if a JTextField has the focus? > thank to all Look there: http://www.catb.org/esr/faqs/smart-questions.html#forum That is an unhelpful response. So we have to ag

Re: focus on jtextfield

2012-09-04 Thread Andreas Perstinger
On 04.09.2012 11:34, Paolo wrote: how do I know if a JTextField has the focus? thank to all Look there: http://www.catb.org/esr/faqs/smart-questions.html#forum Bye, Andreas -- http://mail.python.org/mailman/listinfo/python-list

Re: Cut out XML subtree

2012-08-29 Thread Andreas Perstinger
On Wed, 29 Aug 2012 18:17:18 +0200 Florian Lindner wrote: > I want to cut out an XML subtree like that: [snip] > Is there a way I can do that using etree or DOM? The first is > prefered... Python 3.2.2 (default, Sep 5 2011, 22:09:30) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" o

Re: Python list archives double-gzipped?

2012-08-27 Thread Andreas Perstinger
On 27.08.2012 03:40, Tim Chase wrote: So it looks like some python-list@ archiving process is double gzip'ing the archives. Can anybody else confirm this and get the info the right people? In January, "random joe" noticed the same problem[1]. I think, Anssi Saari[2] was right in saying that th

Re: help me debug my "word capitalizer" script

2012-08-22 Thread Andreas Perstinger
On 22.08.2012 08:21, Santosh Kumar wrote: with open(givenfile) as file: # List to store the capitalised lines. lines = [] for line in file: # Split words by spaces. words = line.split(' ') The last element in your "words" list will still have a newline characte

Re: Beautiful Soup Table Parsing

2012-08-09 Thread Andreas Perstinger
On 09.08.2012 01:58, Tom Russell wrote: For instance this code below: soup = BeautifulSoup(urlopen('http://online.wsj.com/mdc/public/page/2_3021-tradingdiary2.html?mod=mdc_pastcalendar')) table = soup.find("table",{"class": "mdcTable"}) for row in table.findAll("tr"): for cell in row.find

Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-12 Thread Andreas Perstinger
On Thu, 12 Jul 2012 16:59:06 +1000 Chris Angelico wrote: > On Thu, Jul 12, 2012 at 3:35 PM, Andreas Perstinger > wrote: > > Do you mean this license?: > > http://packages.python.org/PollyReports/license.html > > > > It's the standard license for NetBSD pro

Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-11 Thread Andreas Perstinger
On Thu, 12 Jul 2012 10:41:52 +1000 Simon Cropper wrote: > That said... with more than a passing interest in software and > content licensing I looked at how the work was licensed. A > none-standard license like this makes most people stop and think > "will this be a problem if I use this in my w

Re: Learning Python 2.4

2011-12-21 Thread Andreas Perstinger
On 2011-12-20 19:31, kimma wrote: I am about to learn python with "how to think like a computer scientist". This book is just available for python 2.4. Does it matter for programming? There is also a online-version for Python 3 but there are some differences: http://openbookproject.net/thinkcs/

Re: sick of distribute, setup, and all the rest...

2011-11-28 Thread Andreas Perstinger
On 2011-11-28 14:14, rusi wrote: On Nov 28, 4:42 pm, Steven D'Aprano wrote: We don't chase people down on the street and lecture them about the problems we think they are having, we answer questions about ACTUAL problems that they have experienced and asking about. ... ever question gets

Re: Trying to write beautifulsoup result to a file and get error message

2011-11-14 Thread Andreas Perstinger
On 2011-11-13 23:37, goldtech wrote: If I try: ... soup = BeautifulSoup(ft3) f = open(r'c:\NewFolder\clean4.html', "w") f.write(soup) f.close() I get error message: Traceback (most recent call last): File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line 203, in f.write(soup)

Re: Python lesson please

2011-11-07 Thread Andreas Perstinger
On 2011-11-07 12:22, gene heskett wrote: On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: Are you talking about this one? https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns .py Yes. My save as renamed it, still has about 30k of tabs in it. But I pulle

Re: Python gp.ListFeatureClasses return only one file

2011-10-13 Thread Andreas Perstinger
On 2011-10-13 14:00, yo wrote: Hi All, I m using the gp.ListFeatureClasses to make a list of file in my directory (containing several hundreds of file) however when I print the variable in which the List is supposed to be stored, the print just return one file name does any one have an idea??

Re: file processing question

2011-10-12 Thread Andreas Perstinger
On 2011-10-12 13:15, selahattin ay wrote: hi all, I wrote these codes but the program must write the prints to a text file... code = [100, 200, 300, 400, 500] list= [] a = 0 while a< 9: a+=1 list.append(a) last_list = [[int(str(i) + str(k)) for i in code] for k in list] list2= []

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Andreas Perstinger
On 2011-09-11 13:17, Kayode Odeyemi wrote: On Sun, Sep 11, 2011 at 11:41 AM, Thomas Jollans wrote: It is working: >>> class A(object): ... def log (self, module): ... return str ('logged') ... >>> class B(A): ... def __init__(self, module): ... self.module = A