Find day of week from month and year
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks with the functions provided by the built-in module time, but the problem was that the 9 element tuple need to be populated correctly. Can anyone help me out on this one? Thanks a bunch, Laguna Requirements: d0 = expiration(9, 2005) # d0 would be 16 d1 = expiration(6, 2003) # d1 would be 20 d2 = expiration(2, 2006) # d2 would be 17 -- http://mail.python.org/mailman/listinfo/python-list
Re: Find day of week from month and year
> What do you mean by, "the 9 element tuple need to be populated > correctly"? Do you need someone to tell you what values it > needs? What happens if you use (2005, 9, 1, 0, 0, 0, 0, 0, 0), > for example? If you make this tuple with localtime or gmtime, > do you know what the 7th (tm[6]) element of the tuple is? > What tricks did you try, exactly? > >Donn Cave, [EMAIL PROTECTED] Thanks for pointing out. tm[6] = weekday, and tm[7] = Julian data, but I wouldn't know these values when my input values are month and year. I will try out the more constructive suggestions from Paul and Robert. Following is what I have tried. As you can tell, the results are wrong! >>> import time >>> time.asctime((2003, 9, 1, 0, 0, 0, 0, 0, 0)) 'Mon Sep 01 00:00:00 2003' >>> time.asctime((2003, 8, 1, 0, 0, 0, 0, 0, 0)) 'Mon Aug 01 00:00:00 2003' >>> time.asctime((2003, 7, 1, 0, 0, 0, 0, 0, 0)) 'Mon Jul 01 00:00:00 2003' -- http://mail.python.org/mailman/listinfo/python-list
Re: Find day of week from month and year
Paul, Thanks for the suggestion on calendar module. Here is my solution and it works: def expiration(year, month): weekday = calendar.weekday(year, month, 1) table = [19, 18, 17, 16, 15, 21, 20] return table[weekday] Cheers, Laguna -- http://mail.python.org/mailman/listinfo/python-list
Re: Find day of week from month and year
Thanks for the "hint" :) I may use your solution if this becomes my bottleneck! I try to get away from Perl-ish syntax though. Best, L -- http://mail.python.org/mailman/listinfo/python-list
Re: Find day of week from month and year
Hey Donn, I don't mean to offend anyone here. I was just saying that the other solution is better suited for my problem. I truly appreciate your analysis and suggestions. BTW, I am not a programmer :( and I like the simplest solution whenever possible. Cheers, L -- http://mail.python.org/mailman/listinfo/python-list
Ide RAD for linux?
Suse 9.3 Ide RAD for linux? Tanks -- http://mail.python.org/mailman/listinfo/python-list
E' possibile integrare ironpython con visual studio 2005?
Se si come? Ciao by Enzo -- http://mail.python.org/mailman/listinfo/python-list
Convert a long XML string into indented format
Hi, I have an XML file in a single long string. How can I convert it into the nicely indented format as displayed by Internet Explorer using Python? Thanks, Laguna Input XML file (one continuous string without newline): */2 * * * * Output XML file: */2 * * * * -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert a long XML string into indented format
Excellent! This is exactly what I was looking for. Thank you Jim! My example code: import xml.dom.ext import xml.dom.minidom doc = xml.dom.minidom.parse('myfile.xml') xml.dom.ext.PrettyPrint(doc) -- http://mail.python.org/mailman/listinfo/python-list
py2exe to share binary files
Hi, With py2exe-0.3.3 for Python 2.2 in Windows XP, how to configure setup.py such that multiple executables can share the dll files (like wx*.dll etc.) as follows: # Source folders \Program1 Program1.py Program1WX.py \Program2 Program2.py Program2WX.py # Output binary folders \SharedBinary _sre.dll bsddb.pyd python22.dll utilsc.pyd wxc.pyd wxmsw232.dll \Executable1 Program1.exe \Executable2 Program2.exe Thanks for any help, Laguna -- http://mail.python.org/mailman/listinfo/python-list
Installing addition libraries in Portable Python 2.7 on Windows
I am new in Python, I have Portable Python 2.7.5.1 installed on Windows 7. I want to install additional libraries: python-magic libmagic libfuzzy pyqtgraph I downloaded package, saved on hard drive, unzipped, find setup.py and tried install via Command Prompt: Python-Portable.exe setup.py install A new DOS terminal window briefly flashes and disappears, without showing any error or installation confirmation. I assume that nothing has been installed and/or installation failed.. No tips or errors has been shown, so I don't' know how to install these packages corretcly. I tried also to install get-pip.py use same way, and again nothing happens, no any errors or results. -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing addition libraries in Portable Python 2.7 on Windows
It'slike a chain, eachnew modulepulls afew othermodules.I can postpone get-pip.py onthe very last stage, now I want to install python-magic, libmagic, libfuzzy, pyqtgraph. How to do this? - Original Message - From: Mark Lawrence Sent: 03/16/14 05:06 PM To: python-list@python.org Subject: Re: Installing addition libraries in Portable Python 2.7 on Windows On 16/03/2014 13:50, laguna...@mail.com wrote: > I am new in Python, I have Portable Python 2.7.5.1 installed on Windows 7. > > I want to install additional libraries: > > python-magic > libmagic > libfuzzy > pyqtgraph > > I downloaded package, saved on hard drive, unzipped, find setup.py and > tried install via Command Prompt: > > Python-Portable.exe setup.py install > > A new DOS terminal window briefly flashes and disappears, without > showing any error or installation confirmation. > I assume that nothing has been installed and/or installation failed.. No > tips or errors has been shown, so I don't' know how to install these > packages corretcly. > I tried also to install get-pip.py use same way, and again nothing > happens, no any errors or results. > IIRC you need to obtain ez_setup.py to get easy_install and only then will get-pip.py work. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is f ree from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Error when installing matplotlib-1.3. on Windows
I'm trying to install matplotlib from locally stored source archive file (Portable Python 2.7 on Windows): pip install E:\matplotlib-1.3.1.win32-py2.7.exe Got error, below is log: E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 03:10:16 Exception: Traceback (most recent call last): File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py", line 122, in main status = self.run(options, args) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\commands\install.py", line 257, in run InstallRequirement.from_line(name, None)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 172, in from_line return cls(req, comes_from, url=url, prereleases=prereleases) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 70, in __init__ req = pkg_resources.Requirement.parse(req) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in parse reqs = list(parse_requirements(s)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in parse_requirements line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in scan_list raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) ValueError: ('Expected version spec in', 'E:\\matplotlib-1.3.1.win32-py2.7.exe', 'at', ':\\matplotlib-1.3.1.win32-py2.7.exe') What is the problem and how to solve it? -- https://mail.python.org/mailman/listinfo/python-list
Installing binwalk on Portable Python
Portable Python 2.7 for Win32 and installed on USB flash drive. I want install Binwalk tool, it have a few depencencies, I installed it first (numpy, matplotlib, libmagic, python-magic) Then I tried to install binwalk from locally stored source archive file, I tried two ways: pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0.tar pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0\src\setup.py I both cases I got error, below is log: E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 21:25:47 Exception: Traceback (most recent call last): File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py", line 122, in main status = self.run(options, args) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\commands\install.py", line 257, in run InstallRequirement.from_line(name, None)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 172, in from_line return cls(req, comes_from, url=url, prereleases=prereleases) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 70, in __init__ req = pkg_resources.Requirement.parse(req) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in parse reqs = list(parse_requirements(s)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in parse_requirements line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in scan_list raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) ValueError: ('Expected version spec in', 'E:\\Portable', 'at', ':\\Portable') --- What is wrong with this? -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing binwalk on Portable Python
I tried: pip install "E:\Portable Python 2.7.5.1\binwalk-1.3.0\src\setup.py" Error: E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 22:53:51 Exception: Traceback (most recent call last): File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py", line 122, in main status = self.run(options, args) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\commands\install.py", line 257, in run InstallRequirement.from_line(name, None)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 172, in from_line return cls(req, comes_from, url=url, prereleases=prereleases) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line 70, in __init__ req = pkg_resources.Requirement.parse(req) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in parse reqs = list(parse_requirements(s)) File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in parse_requirements line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in scan_list raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) ValueError: ('Expected version spec in', 'E:\\Portable Python 2.7.5.1\\binwalk-1.3.0\\src\\setup.py', 'at', ':\\Portable Python 2.7.5.1\\binwalk-1.3.0\\src\\setup.py') -- - Original Message - From: Peter Mawhorter Sent: 03/17/14 10:13 PM To: laguna...@mail.com Subject: Re: Installing binwalk on Portable Python On Mon, Mar 17, 2014 at 12:56 PM, wrote: > Portable Python 2.7 for Win32 and installed on USB flash drive. I want > install Binwalk tool, it have a few depencencies, I installed it first > (numpy, matplotlib, libmagic, python-magic) > Then I tried to install binwalk from locally stored source archive file, I > tried two ways: > > pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0.tar > > pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0\src\setup.py > > I both cases I got error, below is log: > > E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 21:25:47 > Exception: > Traceback (most recent call last): > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\basecommand.py", line 122, in main > status = self.run(options, args) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\commands\install.py", line 257, in run > InstallRequirement.from_line(name, None)) > File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", lin e > 172, in from_line > return cls(req, comes_from, url=url, prereleases=prereleases) > File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line > 70, in __init__ > req = pkg_resources.Requirement.parse(req) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in > parse > reqs = list(parse_requirements(s)) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in > parse_requirements > line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in > scan_list > raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) > ValueError: ('Expected version spec in', 'E:\\Portable', 'at', > ':\\Portable') > --- > > > > What is wrong with this? > -- > https://mail.python.org/mailman/listinfo/python-list > From your error it looks like you just need quotes around the path because it has a space in it. -Peter Mawhorter -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing binwalk on Portable Python
Yes, that help. Installation start, but then failed due to "Pre-requisite failure: failed to find libmagic. Check your installation. Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/' " Although libmagic was installed using pip. - Original Message - From: Peter Mawhorter Sent: 03/17/14 11:07 PM To: laguna-mc Subject: Re: Installing binwalk on Portable Python On Mon, Mar 17, 2014 at 1:58 PM, wrote: > I tried: pip install "E:\Portable Python > 2.7.5.1\binwalk-1.3.0\src\setup.py" > > Error: > > E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 22:53:51 > > Exception: > Traceback (most recent call last): > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\basecommand.py", line 122, in main > status = self.run(options, args) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\commands\install.py", line 257, in run > InstallRequirement.from_line(name, None)) > File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line > 172, in from_line > return cls(req, comes_from, url=url, prereleases=prereleases) > File "E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py", line > 70, in __init__ > req = pkg_resources.Requirement.parse(req) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in > parse > reqs = list(parse_requirements( s)) > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in > parse_requirements > line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") > File "E:\Portable Python > 2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in > scan_list > raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) > ValueError: ('Expected version spec in', 'E:\\Portable Python > 2.7.5.1\\binwalk-1.3.0\\src\\setup.py', 'at', ':\\Portable Python > 2.7.5.1\\binwalk-1.3.0\\src\\setup.py') > > > -- I'm no expert, but when I try to run pip install ... it seems to want a directory that contains a setup.py file rather than the path of the setup.py file itself. Try: pip install "E:\Portable Python 2.7.5.1\binwalk-1.3.0\src" perhaps? -Peter Mawhorter -- https://mail.python.org/mailman/listinfo/python-list
Installing ssdeep on Portable Python
Portable Python 2.7 for Windows, the Python application have dependency on ssdeep-2.10, which is a binary exe. The ssdeep (libfuzzy) installation example was shown for Linux platform only: a) libfuzzy can be installed via apt-get: $ sudo apt-get install libfuzzy2 b) to install libfuzzy from source, download the gzipped tarball from http://ssdeep.sourceforge.net/#download, then run: $ tar -zxvf ssdeep-2.10.tar.gz $ cd ssdeep-2.10 && ./configure && make && sudo make install - I need install it on PortablePython for Windows, so it's not clear how to make this: where should be placed ssdeep Windows binary files, that Python application can found it? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Installing ssdeep on Portable Python /advice
Portable Python 2.7 for Windows, the Python application have dependency on ssdeep-2.10, which is a binary exe. The ssdeep (libfuzzy) installation example was shown for Linux platform only: a) libfuzzy can be installed via apt-get: $ sudo apt-get install libfuzzy2 b) to install libfuzzy from source, download the gzipped tarball from http://ssdeep.sourceforge.net/#download, then run: $ tar -zxvf ssdeep-2.10.tar.gz $ cd ssdeep-2.10 && ./configure && make && sudo make install - I need install it on PortablePython for Windows, so it's not clear how to make this: where should be placed ssdeep Windows binary files, that Python application can found it? -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing ssdeep on Portable Python /advice
http://ssdeep.sourceforge.net/usage.html the installation described in aboved document is for Linux only. Well, I need experiment and see errors. Regards, > - Original Message - > From: Mark H Harris > Sent: 03/22/14 05:32 AM > To: python-list@python.org > Subject: Re: Installing ssdeep on Portable Python /advice > > On 3/21/14 9:51 PM, Mark H Harris wrote: > > On 3/20/14 7:16 PM, laguna...@mail.com wrote: > > >> $ tar -zxvf ssdeep-2.10.tar.gz > >> $ cd ssdeep-2.10&& ./configure&& make&& sudo make install > > >> I need install it on PortablePython for Windows, so it's not > >> clear how to make this: where should be placed ssdeep Windows > >> binary files, that Python application can found it? > > > It is strongly recommended that ssdeep be run on windows from > > precompiled binaries. Building from sources is not recommended because > > of dependencies and environment... > > > Google is our frined; > > > http://ssdeep.sourceforge.net/usage.html > > > Actually, I restated that wrong. The doc says that building from sources > on windows is NOT supported. > > marcus > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Unpacking U-Boot image file
I know about Binwalk, it can run on Linux OS only. I am looking for Python script that can run on Windows too. Thank you. - Original Message - From: Adnan Sadzak Sent: 04/09/14 11:37 PM To: trewio Subject: Re: Unpacking U-Boot image file Oh then see Craig's page [0]. You can find in deepth explanation about some tools (Linux) that is used to desompress and mount filesystems/images. From my experience you should find first read modem tehnical documentation. Find out what kind of firmware is using. You won't find just script to decompress those images. [0] http://www.devttys0.com/2011/05/reverse-engineering-firmware-linksys-wag120n/ Cheers On Wed, Apr 9, 2014 at 7:53 PM, trewio < laguna...@mail.com > wrote:U-Boot format: hmm, I'm not sure, can someone specify Python script that will help me deterermine U-boot format used? [for Python for Windows OS] Note: I need Python script for Python under Windows OS. > - Original Message - > From: Rustom Mody > Sent: 04/09/14 08:18 PM > To: python-list@python.org > Subject: Re: Unpacking U-Boot image file > > On Wednesday, April 9, 2014 9:36:40 PM UTC+5:30, trewio wrote: > > How to extract files from U-Boot image file, LZMA-compressed? > > > > Is there a Python script that can do this properly? > > For lzma theres this (recent) python library > https://docs.python.org/dev/library/lzma.html > > Though you might just be better off with the command-line xz unxz etc > > After that.. whats the U-boot format? > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list