Re: A desperate lunge for on-topic-ness
On Mon, Oct 22, 2012 at 5:30 PM, Steven D'Aprano wrote: > For languages without static types, what other reasons for declaring > variables are there? The main one is scope nesting. Compare a few different languages. Python: If you don't declare, it's global if you don't rebind it, but local if you do. You may declare variables as global or nonlocal. PHP: If you don't declare, it's local, but functions are in a separate scope. C: If you don't declare, it's looked for in some broader scope. If it's not declared in any scope, error. All three approaches make reasonable sense. The PHP one is perfectly consistent, but would be hopelessly impractical if all your function names had to be marked off as globals. (Plus PHP has superglobals, with their own Marvellous mess.) Python's system "just works" most of the time, but can introduce yet another trap for the unsuspecting newbie who doesn't understand the difference between rebinding and mutating; I've not looked into multiple levels of closures but I suspect there'll be odd limitations there, as there's only one "nonlocal" keyword. The C style has administrative overhead (requiring explicit declarations for all variables), but allows full flexibility (variables having narrower scope than entire functions, infinite nesting of scopes, etc). Incidentally, variable declarations don't have to be connected with static typing. JavaScript/ECMAScript simply has 'var x;' to declare that x exists in this function. But it's hardly a language that I'd hold up as a shining example; a var declaration anywhere in a function makes that variable name local to that entire function. There's actually no block scoping at all. And then there's the whole confusion of the global object, 'this', and 'with' statements... You knew I was going to cite it sooner or later :) Pike has true block scoping, though unlike C++, Pike does not guarantee that destructors will be called immediately at the close brace (but zero-reference objects will be cleaned up, including destructor calls, at the next function return - even if not the current function). Variables can be mostly-statically-typed, or can be declared as 'mixed' and be rebound freely (like in JS and Python). So scoped variable declarations and static typing are quite orthogonal. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python does not take up available physical memory
On 21 Oct 2012, at 15:14, Pradipto Banerjee wrote: > I tried this on a different PC with 12 GB RAM. As expected, this time, > reading the data was no issue. I noticed that for large files, Python takes > up 2.5x size in memory compared to size on disk, for the case when each line > in the file is retained as a string within a Python list. As an anecdote, for > MATLAB, the similar overhead is 2x, slightly lower than Python, and each line > in the file was retained as string within a MATLAB cell. I'm curious, has any > one compared the overhead of data in memory for other languages like for > instance Ruby? > Python 3.3 has changes to make string storage more efficient. See the whats new page. http://docs.python.org/py3k/whatsnew/3.3.html "more compact unicode strings". Barry -- http://mail.python.org/mailman/listinfo/python-list
Compiling extension module (linker error)
I am trying to compile an extension module with C++ Builder 6 for Python 3.3.
I converted python33.lib using coff2omf.exe and added this library
into my project.
I wonder why I get this error message while building:
[Linker Error] Unresolved external '_PyModule_Create2TraceRefs'
referenced from 'D:\WORK\FROMAGE\OUT\ROSE_UNIT.OBJ'
My source file:
//---
#include
#include
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
static PyObject* __declspec(dllexport) testik(PyObject* self, PyObject* args)
{
return NULL;
}
static PyMethodDef FundRoseMethods[] = {
{"testik", testik, METH_VARARGS, "perform a test"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef FundRoseModule = {
PyModuleDef_HEAD_INIT,
"FundRose",
NULL,
-1,
FundRoseMethods
};
PyMODINIT_FUNC
PyInit_FundRose(void)
{
return PyModule_Create(&FundRoseModule);
}
//---
--
http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
In article <[email protected]>, Steven D'Aprano wrote: > On Mon, 22 Oct 2012 07:22:18 +1100, Chris Angelico wrote: > > > On Mon, Oct 22, 2012 at 6:11 AM, Steven D'Aprano > > wrote: > > >>> Ahh. I totally didn't see that, I'm way too used to reading past > >>> typos. > >> > >> As a programmer, doesn't that screw up your debugging ability? > > > > Reading-past-typos applies mainly to English, which is a pretty > > redundant language. In code, it would only apply to variable names; with > > (effectively) single words/tokens standing alone, the automatic > > correction doesn't really apply. But yes, sometimes I have stared at a > > piece of code for a long time without knowing why there's an error on > > line X. (This is another good reason to require that all variables be > > declared, incidentally. I might have a variable called "source" but not > > "souce", so using the other causes an instant compile-time failure on > > the exact line with the bug.) > > "Another" good reason? > > For languages without static types, what other reasons for declaring > variables are there? Variable declarations serve two purposes. One is to declare the type (which obviously doesn't apply to Python). The other is to declare the beginning of a scope. On occasion, I will make typos in variable names which a scope-introduction declaration would have prevented. If the cost of having to declare every variable would be justified by the rare bug it would prevent, is another question. Pet peeve of the day... Why do you have to write: global foo foo = 4 when global foo = 4 would have been so much easier? -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 13:51:35 +1100, Ben Finney wrote: > Walter Hurry writes: > >> It is Google bloody Groups which is the problem. I should have plonked >> posts from there ages ago, and am about to remedy that omission. > > What narrowly-defined, precise filter rule should be used for this > purpose? Depends on how you read the list, I think. In my case, via Usenet (comp.lang.python) with Pan, so I shall filter on "googlegroups.com" in the Message-ID. -- http://mail.python.org/mailman/listinfo/python-list
Re: Blue Screen Python
Il giorno venerdì 21 settembre 2012 16:04:48 UTC+2, mikcec82 ha scritto: > Hallo to all, > > > > I'm using Python 2.7.3 with Windows 7 @ 64 bit > > and an Intel Core i3 -2350M CPU @2.30GHz 2.3GHz. > > > > Sometimes, when I'm programming in Python on my screen compare this blue > screen: > > http://imageshack.us/a/img228/8352/48579647436249494527021.jpg > > > > Can you help on what is the issue, and how I can solve it? > > > > If you need more info I'm available. > > > > Thank you so much, > > Michele Hi to all. I solved the problem by creating a WINDOWS XP Virtual Machine (by installing Windows Remote Pc). In this way I have no more problems. I hope this could be helpful to other people. Have a nice day, Michele -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 10/21/2012 9:19 PM, Ian Foote wrote: On 22/10/12 09:03, Emile van Sebille wrote: So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? Because not only the newbie will read the thread? I for one was interested to see all the different possible approaches, and their upsides and downsides. Fair -- I get concerned that newcomers are faced with a much higher cost of entry when answers to their apparently simple problems require knowledge of specific functions in specific library modules to solve. This presents a very high bar as my quick local test (help(); modules) shows 398 modules! In this case the only requirement should have been a quick pass through the tutorial which should be enough to solve most problems. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
> On Fri, 19 Oct 2012 21:21:11 -0700 (PDT), [email protected] declaimed the > following in gmane.comp.python.general: > >> [I posted the following in another thread yesterday...] >> >> When you post from Google Groups you will sometimes >> see a checkbox above the edit window that is a cc to >> the python mailing list () >> which is checked by default. >> >> If you uncheck that, you'll stop the double posting. > > That is different from the Google Groups double-spacing ">" quoted > material. Yes, I realized that right after I clicked send. However since it is also a common problem when posting from GG, maybe some other readers of this thread will find it useful. Re the specific problem mentioned, I just paste the original message into an emacs window, add the quote marks and paste back into the GG compose window. Another alternative is to use "paste as quotation" into a mail client compose window, and then paste back into GG. A small PITA but not a big deal if GG is otherwise convenient. But perhaps the same mentality that makes it just sooo hard to read a double spaced post (that one is willing to killfile a whole class of participants) is the same mentality that makes sooo hard to correct such posts to begin with. -- http://mail.python.org/mailman/listinfo/python-list
Re: program loaded in memory
On 2012-10-22, Steven D'Aprano wrote: > On Mon, 22 Oct 2012 02:02:27 +0200, Anatoli Hristov wrote: > >> Hello, >> >> I need an advice about a small script I run 24/24 7/7. >> >> It's a script converted to EXE using py2exe and this script takes - >> grows 30kb RAM on each loop which means that for 10hours it grows up >> with 180mb memory. is there something I can do ? > > Probably. Find the memory leak and fix it. > > What happens if you call it directly from Python, instead of using py2exe? > Perhaps the memory leak is in py2exe. I'm curious how there can be a memory leak in py2exe. I thought all it did was bundle up the python interpreter and the required libraries into a "private" python installation that's then invoked by the wrapper. Does py2exe actually do something after the application has started? -- Grant Edwards grant.b.edwardsYow! ONE LIFE TO LIVE for at ALL MY CHILDREN in ANOTHER gmail.comWORLD all THE DAYS OF OUR LIVES. -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On 2012-10-22, Walter Hurry wrote: > On Mon, 22 Oct 2012 13:51:35 +1100, Ben Finney wrote: > >> Walter Hurry writes: >> >>> It is Google bloody Groups which is the problem. I should have plonked >>> posts from there ages ago, and am about to remedy that omission. >> >> What narrowly-defined, precise filter rule should be used for this >> purpose? > > Depends on how you read the list, I think. In my case, via Usenet > (comp.lang.python) with Pan, so I shall filter on "googlegroups.com" in > the Message-ID. Same here. Here's the rule I have in slrn's .score file: Score:: =- Message-ID: .*googlegroups.com -- Grant Edwards grant.b.edwardsYow! Where does it go when at you flush? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 14:21:36 +, Grant Edwards wrote: > On 2012-10-22, Walter Hurry wrote: >> On Mon, 22 Oct 2012 13:51:35 +1100, Ben Finney wrote: >> >>> Walter Hurry writes: >>> It is Google bloody Groups which is the problem. I should have plonked posts from there ages ago, and am about to remedy that omission. >>> >>> What narrowly-defined, precise filter rule should be used for this >>> purpose? >> >> Depends on how you read the list, I think. In my case, via Usenet >> (comp.lang.python) with Pan, so I shall filter on "googlegroups.com" in >> the Message-ID. > > Same here. Here's the rule I have in slrn's .score file: > > Score:: =- > Message-ID: .*googlegroups.com Actually I don't think the asterisk is necessay*. OTOH, I noticed that some are "To: [email protected]", so I put in a second rule: Score:: =- Message-ID: googlegroups\.com Score:: =- To: googlegroups\.com * Or maybe the sytax differs slightly between slrn and Pan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 07:07:20 -0700 (PDT) [email protected] wrote: > Re the specific problem mentioned, I just paste the original > message into an emacs window, add the quote marks and paste back > into the GG compose window. If you are on Firefox you should check out the "It's All Text!" plugin. Not sure if it is available for other browsers. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 14:35:58 +, HoneyMonster wrote: Sorry about the moniker on the above. I used it by accident - it's one I reserve for junk trapping. -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 14:21:36 + (UTC) Grant Edwards wrote: > Same here. Here's the rule I have in slrn's .score file: Here is the procmail one that I use: :0 Hir * ^List-Id:.*python-list.python.org * ^From:.*@gmail.com * ^Newsgroups: /dev/null This still allows people using a gmail account to post to the mailing list through. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to programmatically turn on remote registry?
Back at it this morning. The RPC was due to needing to run it under another account (or so I think now...). However, the RemoteRegistry service is not just STOPPED but DISABLED. I am trying to see if there is a call to actually set the state to MANUAL. Then I can star the registry, grab what I need, stop the service, then set it back to disabled Does anyone know if there is a way to do this? Thanks for your help. Kevin On Fri, Oct 19, 2012 at 8:56 PM, Dennis Lee Bieber wrote: > On Fri, 19 Oct 2012 17:19:56 -0400, Kevin Holleran > declaimed the following in gmane.comp.python.general: > > > Thanks! I think this is getting me on the right track. Now when I > attempt > > to start the RemoteRegistry service I am getting an exception "The RPC > > server is unavailable." However, I am done with this for today so back > at > > it on Monday. > > > > Apparently you are under a VERY locked down network... > > RPC is another service you may have to start -- problem: you can't > start it from a remote connection as the remote connection needs to use > RPC . It may be faster to just telnet to each machine, logging in as > admin, and then piping the shell commands to do the changes to the > telnet session... > -- > Wulfraed Dennis Lee Bieber AF6VN > [email protected]://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to programmatically turn on remote registry?
On 22/10/2012 15:51, Kevin Holleran wrote: > Back at it this morning. The RPC was due to needing to run it under > another account (or so I think now...). However, the RemoteRegistry > service is not just STOPPED but DISABLED. > > I am trying to see if there is a call to actually set the state to > MANUAL. Then I can star the registry, grab what I need, stop the > service, then set it back to disabled > > Does anyone know if there is a way to do this? Can you connect to the remote machine via WMI? (If the remote registry service is stopped, WMI might be also). If so, you can access the registry remotely via WMI: http://timgolden.me.uk/python/wmi/cookbook.html#list-registry-keys Ultimately, you need *something* on the remote machine to be running which will accept incoming requests. If nothing is (because the machine & network are secured) then you're not going to be able to do what you want. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to programmatically turn on remote registry?
Thanks, I will look into that. WMI is enabled, but everything WMI query I wrote (& I am NOT a WMI expert or even close) gave me a bunch of NIC info, but not the info I am after in the registry (driver description, driver date, driver version for the NICs). Thanks for your help. Kevin On Mon, Oct 22, 2012 at 11:05 AM, Tim Golden wrote: > On 22/10/2012 15:51, Kevin Holleran wrote: > > Back at it this morning. The RPC was due to needing to run it under > > another account (or so I think now...). However, the RemoteRegistry > > service is not just STOPPED but DISABLED. > > > > I am trying to see if there is a call to actually set the state to > > MANUAL. Then I can star the registry, grab what I need, stop the > > service, then set it back to disabled > > > > Does anyone know if there is a way to do this? > > Can you connect to the remote machine via WMI? (If the remote registry > service is stopped, WMI might be also). If so, you can access the > registry remotely via WMI: > > > http://timgolden.me.uk/python/wmi/cookbook.html#list-registry-keys > > Ultimately, you need *something* on the remote machine to be running > which will accept incoming requests. If nothing is (because the machine > & network are secured) then you're not going to be able to do what you > want. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
some godd python blog?
-- http://mail.python.org/mailman/listinfo/python-list
ANN: Central Python Events Calendar
[Please help spread the word by forwarding to other relevant mailing lists, user groups, etc. world-wide; thanks] ANNOUNCING Central Python Events Calendars maintained by the Python Software Foundation (PSF) and a group of volunteers INTRODUCTION The PSF has put together a team of volunteers who are maintaining a central Python events calendar. We currently have two calendars in place: * Python Events Calendar - meant for conferences and larger gatherings focusing on Python or a related technology (in whole or in part) * Python User Group Calendar - meant for user group events and other smaller local events The calendars are displayed on http://pycon.org/ and in a smaller version in the sidebar of the http://python.org/ website (at the moment only the main events calendar is shown there). ADDING EVENTS If you want to have entries added to those calendars, please write to [email protected] and include the following information: * Name of the event * Type of the event (conference, bar camp, user group, etc) * Focus on Python * URL * Location and country * Date and time (if relevant) For recurring events, please also include a description of the recurrence in a way that's compatible and supported by Google calendars. MORE INFORMATION More information on the calendars, the URLs, feed links, IDs, embedding, etc. is available on the wiki: http://wiki.python.org/moin/PythonEventsCalendar Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 22 2012) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2012-09-27: Released eGenix PyRun 1.1.0 ... http://egenix.com/go35 2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34 2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33 2012-10-23: Python Meeting Duesseldorf ... tomorrow eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On 10/21/2012 11:33 AM, Vincent Davis wrote: > I am looking for a good way to get every pair from a string. For example, > input: > x = 'apple' > output > 'ap' > 'pp' > 'pl' > 'le' Maybe zip before izip for a noob? >>> s="apple" >>> [a+b for a,b in zip(s, s[1:])] ['ap', 'pp', 'pl', 'le'] >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: some godd python blog?
On 22/10/2012 17:01, nepaul wrote: Try using a search engine for specific Python issues that you'd like to read up on. If you can't find what you want please ask a specific question, that way you're far more likely to get some answers. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Central Python Events Calendar
> ANNOUNCING > Central Python Events Calendars Thanks, a great idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling extension module (linker error)
On 2012-10-22 11:55, Paul Volkov wrote:
I am trying to compile an extension module with C++ Builder 6 for Python 3.3.
I converted python33.lib using coff2omf.exe and added this library
into my project.
I wonder why I get this error message while building:
[Linker Error] Unresolved external '_PyModule_Create2TraceRefs'
referenced from 'D:\WORK\FROMAGE\OUT\ROSE_UNIT.OBJ'
My source file:
//---
#include
#include
#pragma argsused
It's a Python module with its own initialiser, so you don't need this:
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
You don't need to export this function because it's listed in the
module's function table:
static PyObject* __declspec(dllexport) testik(PyObject* self, PyObject* args)
{
Returning NULL says that an exception was raised. You should set the
exception.
return NULL;
}
static PyMethodDef FundRoseMethods[] = {
{"testik", testik, METH_VARARGS, "perform a test"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef FundRoseModule = {
PyModuleDef_HEAD_INIT,
"FundRose",
NULL,
-1,
FundRoseMethods
};
PyMODINIT_FUNC
PyInit_FundRose(void)
{
return PyModule_Create(&FundRoseModule);
}
//---
By the way, the recommendation is for module names to be lowercase with
underscores, so "fund_rose" instead of "FundRose".
Try this code:
#include
#include
#pragma argsused
static PyObject* testik(PyObject* self, PyObject* args)
{
PyErr_SetString(PyExc_RuntimeError, "testik exception");
return NULL;
}
static PyMethodDef FundRoseMethods[] = {
{"testik", testik, METH_VARARGS, "perform a test"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef FundRoseModule = {
PyModuleDef_HEAD_INIT,
"FundRose",
NULL,
-1,
FundRoseMethods
};
PyMODINIT_FUNC PyInit_FundRose(void) {
return PyModule_Create(&FundRoseModule);
}
--
http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
Hello rusi
This is a little bit faster:
s = "apple"
[s[i:i+2] for i in range(len(s)-1)]
>>> timeit("""s = "apple"
... [a+b for a,b in zip(s, s[1:])]""",number=1)
0.061038970947265625
>>> timeit("""s = "apple"
... [s[i:i+2] for i in range(len(s)-1)]""",number=1)
0.0467379093170166
Regards
From: rusi
Date: 22 October 2012 17:19:35 IST
To: [email protected]
Subject: Re: get each pair from a string.
On 10/21/2012 11:33 AM, Vincent Davis wrote:
I am looking for a good way to get every pair from a string. For
example,
input:
x = 'apple'
output
'ap'
'pp'
'pl'
'le'
Maybe zip before izip for a noob?
s="apple"
[a+b for a,b in zip(s, s[1:])]
['ap', 'pp', 'pl', 'le']
--
http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to programmatically turn on remote registry?
On 22/10/2012 16:38, Kevin Holleran wrote: Thanks, I will look into that. WMI is enabled, but everything WMI query I wrote (& I am NOT a WMI expert or even close) gave me a bunch of NIC info, but not the info I am after in the registry (driver description, driver date, driver version for the NICs). I assume you've found things like the Win32_NetworkAdapter which doesn't include driver details. If you cared to come across with the registry keys / values you needed I'm sure I could rustle up a sample query to get you on the right path. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Create/Destory Button
On Fri, Oct 19, 2012 at 4:11 PM, wrote: > I am trying to create a button in Tkinter and then when it is pressed > delete it/have it disappear. Does anyone know the simplest script to do > that with. Thanks for your help. > Note that there is a _big_ difference between having a button 'disappear' and having it destroyed or deleted. If it 'disappears', it still exists and can be re-activated whenever you want (as long as you keep an active reference to it). Once you destroy the widget, there is no recovering it. My suggestion is to provide some code that you've tried, and allow people to help explain why it did not work the way you thought it would. And take a look at http://effbot.org/tkinterbook/tkinter-index.htm -- it has proven to be a helpful reference to me. The actual code to do what you want is not complex (it took me ~20 lines), but learning how to do it is quite helpful. Good luck, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to programmatically turn on remote registry?
Tim,
I am looking here:
SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BF9F6FB0-C999-4D19-BED0-144F77E2A9D6}
Enumerating the keys for a BusType == 5, then grabbing the values of
DriverDesc, DriverDate, & DriverVersion.
So I am doing this:
try:
hKey = _winreg.OpenKey (keyPath,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BF9F6FB0-C999-4D19-BED0-144F77E2A9D6}",
0, _winreg.KEY_READ)
i=0
while True:
try:
subkey = _winreg.EnumKey(hKey, i)
i += 1
if (subkey.QueryValueEx(hKey,"BusType") == "5"):
outputline = host + "," +
subkey.QueryValueEx(hKey,"DriverDesc") + "," +
subkey.QueryValueEx(hKey,"DriverDate") + "," +
subkey.QueryValueEx(hKey,"DriverVersion") + "\n"
print outputline
outputFile.write(outputLine)
except WindowsError, e:
# WindowsError: [Errno 259] No more data is available
pass
except:
print "Unable to query registry key for NIC adapters"
Thanks. I am reviewing the WMI Registry piece you sent over right now. I
am certainly open to anyway I can get the info. I have some odd behaviors
across some servers during vulnerability scanning & have a suspicion that
some driver discrepancies on the NIC are to blame.
Kevin
On Mon, Oct 22, 2012 at 3:29 PM, Tim Golden wrote:
> On 22/10/2012 16:38, Kevin Holleran wrote:
>
>> Thanks, I will look into that. WMI is enabled, but everything WMI query I
>> wrote (& I am NOT a WMI expert or even close) gave me a bunch of NIC
>> info, but not the info I am after in the registry (driver description,
>> driver date, driver version for the NICs).
>>
>
> I assume you've found things like the Win32_NetworkAdapter which doesn't
> include driver details. If you cared to come across with the registry keys
> / values you needed I'm sure I could rustle up a sample query to get you on
> the right path.
>
> TJG
>
> --
> http://mail.python.org/**mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
RE: A desperate lunge for on-topic-ness
Roy Smith wrote: > Pet peeve of the day... > > Why do you have to write: > > global foo > foo = 4 > > when > > global foo = 4 > > would have been so much easier? To make it more annoying for people who use globals, duh. :) Ramit Prasad This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Compiler Error for build Python -3.3.0 (Suggestions)
The version of Python I have on my old Solaris boxes is old and isn't supported and dosn't have all the modules that I need.I have downloaded the new 3.3 version and have been trying to compile it and have no luck: After running the ./configure command I run "make" and it gives me the following error.Does anyone know what is wrong here or what to do about this? Is there a location I can download a binary package of this? Sunfreeware looks to be out of business. Thanks gcc -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes-I. -I./Include-DPy_BUILD_CORE -o Python/pythonrun.o Python/pythonrun.c Python/pythonrun.c: In function `PyOS_getsig': Python/pythonrun.c:2545: storage size of `context' isn't known Python/pythonrun.c:2546: warning: implicit declaration of function `sigaction' Python/pythonrun.c:2547: `SIG_ERR' undeclared (first use in this function) Python/pythonrun.c:2547: (Each undeclared identifier is reported only once Python/pythonrun.c:2547: for each function it appears in.) Python/pythonrun.c:2545: warning: unused variable `context' Python/pythonrun.c: In function `PyOS_setsig': Python/pythonrun.c:2588: storage size of `context' isn't known Python/pythonrun.c:2588: storage size of `ocontext' isn't known Python/pythonrun.c:2590: warning: implicit declaration of function `sigemptyset' Python/pythonrun.c:2593: `SIG_ERR' undeclared (first use in this function) Python/pythonrun.c:2588: warning: unused variable `context' Python/pythonrun.c:2588: warning: unused variable `ocontext' make: *** [Python/pythonrun.o] Error 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLAlchemy: How to do Table Reflection and MySQL?
On Oct 20, 6:24 pm, Nick Sabalausky wrote: > Hi, I'm fairly new to Python, and I'm trying to figure out how to use > SQLAlchemy to connect to a MySQL DB and use table reflection to set up > SQLAlchemy's tables. But the SQLAlchemy documentation is gigantic and > frankly kinda making my head spin, so I'm having trouble even finding > any information on how to use its table reflection, mostly just that it > exists and *can* be done, but not so much "how". My web searching has > just been turning up examples of SQLite and manually describing the > tables in Python and having SQLAlchemy create the tables, which isn't > what I'm looking for. > > Is there a simple way to do this somehow? To just connect to a MySQL DB > and use table reflection? i'm not brave enough to dig too deeply into SQLAlchemy, but maybe this will help? : http://kashififtikhar.blogspot.com/2010/07/using-sqlalchemy-reflection-with-pylons.html that came up from googling "sqlalchemy table reflection tutorial". -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
Walter Hurry writes: > On Mon, 22 Oct 2012 13:51:35 +1100, Ben Finney wrote: > > > Walter Hurry writes: > >> It is Google bloody Groups which is the problem. I should have > >> plonked posts from there ages ago, and am about to remedy that > >> omission. > > > > What narrowly-defined, precise filter rule should be used for this > > purpose? > > Depends on how you read the list, I think. In my case, via Usenet > (comp.lang.python) with Pan, so I shall filter on "googlegroups.com" > in the Message-ID. The Message-ID field seems to be preserved in both directions, so I'll use that. Thank you. -- \ “I call him Governor Bush because that's the only political | `\ office he's ever held legally.” —George Carlin, 2008 | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: A desperate lunge for on-topic-ness
On Mon, Oct 22, 2012 at 1:03 AM, Chris Angelico wrote: > Python's system "just works" most of > the time, but can introduce yet another trap for the unsuspecting > newbie who doesn't understand the difference between rebinding and > mutating; I've not looked into multiple levels of closures but I > suspect there'll be odd limitations there, as there's only one > "nonlocal" keyword. On my wishlist for Python is a big, fat SyntaxError for any variable that could be interpreted as either local or nonlocal and is not explicitly declared as either. It would eliminate this sort of confusion entirely and make code that shadows nonlocal variables much more readable. Ideally, the same thing would also be done for locals that shadow globals, but I don't see how that could possibly be enforced at compile time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler Error for build Python -3.3.0 (Suggestions)
On 2012-10-22 22:31, Joe Davis wrote: The version of Python I have on my old Solaris boxes is old and isn't supported and dosn't have all the modules that I need.I have downloaded the new 3.3 version and have been trying to compile it and have no luck: After running the ./configure command I run "make" and it gives me the following error.Does anyone know what is wrong here or what to do about this? Is there a location I can download a binary package of this? Sunfreeware looks to be out of business. Thanks gcc -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes-I. -I./Include-DPy_BUILD_CORE -o Python/pythonrun.o Python/pythonrun.c Python/pythonrun.c: In function `PyOS_getsig': Python/pythonrun.c:2545: storage size of `context' isn't known Python/pythonrun.c:2546: warning: implicit declaration of function `sigaction' Python/pythonrun.c:2547: `SIG_ERR' undeclared (first use in this function) Python/pythonrun.c:2547: (Each undeclared identifier is reported only once Python/pythonrun.c:2547: for each function it appears in.) Python/pythonrun.c:2545: warning: unused variable `context' Python/pythonrun.c: In function `PyOS_setsig': Python/pythonrun.c:2588: storage size of `context' isn't known Python/pythonrun.c:2588: storage size of `ocontext' isn't known Python/pythonrun.c:2590: warning: implicit declaration of function `sigemptyset' Python/pythonrun.c:2593: `SIG_ERR' undeclared (first use in this function) Python/pythonrun.c:2588: warning: unused variable `context' Python/pythonrun.c:2588: warning: unused variable `ocontext' make: *** [Python/pythonrun.o] Error 1 It looks like HAVE_SIGACTION is 1, which says that 'sigaction' is defined, but it's not defined. Try going to where HAVE_SIGACTION is set and change it to 0. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 can't sort memoryviews as they're unorderable
On 21/10/2012 12:24, Mark Lawrence wrote: http://docs.python.org/dev/whatsnew/3.3.html states "memoryview comparisons now use the logical structure of the operands and compare all array elements by value". So I'd have thought that you should be able to compare them and hence sort them, but this is the state of play. Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> memoryview(bytearray(range(5))) == memoryview(bytearray(range(5))) True >>> memoryview(bytearray(range(5))) != memoryview(bytearray(range(5))) False >>> memoryview(bytearray(range(5))) < memoryview(bytearray(range(5))) Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: memoryview() < memoryview() Okay then, let's subclass memoryview to provide the functionality. >>> class Test(memoryview): ... pass ... Traceback (most recent call last): File "", line 1, in TypeError: type 'memoryview' is not an acceptable base type Oh dear. http://docs.python.org/py3k/library/stdtypes.html#typememoryview only gives examples of equality comparisons and there was nothing that I could see in PEP3118 to explain the rationale behind the lack of other comparisons. What have I missed? Anybody? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 can't sort memoryviews as they're unorderable
On Mon, Oct 22, 2012 at 4:58 PM, Mark Lawrence wrote: >> http://docs.python.org/py3k/library/stdtypes.html#typememoryview only >> gives examples of equality comparisons and there was nothing that I >> could see in PEP3118 to explain the rationale behind the lack of other >> comparisons. What have I missed? >> > > Anybody? As best I can tell from googling, it has never been discussed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler Error for build Python -3.3.0 (Suggestions)
Am 22.10.2012 23:31, schrieb Joe Davis: >The version of Python I have on my old Solaris boxes is old and > isn't supported and dosn't have all the modules that I need.I have > downloaded the new 3.3 version and have been trying to compile it and > have no luck: > > After running the ./configure command I run "make" and it gives me the > following error.Does anyone know what is wrong here or what to do > about this? > > Is there a location I can download a binary package of this? > Sunfreeware looks to be out of business. Hello Joe, Can you tell us more about the Solaris box? I'm especially interested in the Solaris version, architecture (sparc or X86_64) and your C compiler. We have Python up and running on a Solaris 10 box (sparc) and a Solaris 11 box (X86_64) with Sun CC and GCC 4.6. You could try to recompile Python with the Sun CC: $ make distclean $ ./configure --without-gcc --config-cache $ make Christian -- http://mail.python.org/mailman/listinfo/python-list
Style help for a Smalltalk-hack
I'm writing some code that does a structured read from formatted binary file.
The code I came up with looks like:
# get the first four bytes, the first gap field
chunk = byteStream.read(4)
while chunk:
# interpret the gap bytes
gap, = struct.unpack('>I', chunk)
# suck off the valveCount
valveCount, = struct.unpack('>I', byteStream.read(4))
# collect the next valveCount signatures
signatures = [struct.unpack('>I', byteStream.read(4))[0] for _ in
range(valveCount)]
self.script.append(ScriptSpan(gap=gap, valveSet=signatures))
# now get the next 4 bytes for the gap of the next iteration, it'll be
empty if we're at end
chunk = byteStream.read(4)
I can't help but thinking that there's some better way (i.e. more pythonic) to
do this that doesn't involve having to use another module (Construct) or
exploring generators or something like that. What bugs me about it is that
there is two different styles for reading/decoding values from the byte stream.
valveCount and signatures are both paired invocations of unpack() and read().
But to detect the end of the stream (file), I have to split the read() and
unpack() of the gap value across 3 different lines of the code, and they don't
even sit adjacent to each other.
I'm wandering up the Python curve with a passel of Smalltalk experience under
my belt, so I expect I'm struggling with trying to map something like this
across to python
[byteStream atEnd] whileFalse: [
gap := (byteStream next: 4) asInteger.
valveCount := (byteStream next: 4) asInteger.
signatures := (1 to: valveCount) collect: [:_ | (byteStream next: 4)
asInteger].
self script add: (ScriptSpan gap: gap valveSet: signatures).
]
The part that doesn't seem to be there in the standard python library is the
idea of an atEnd message for streams, it's inferred as a byproduct of a read().
Please be gentle/kind. I'm still learning. :) TIA
--
Travis Griggs
"A vital ingredient of success is not knowing that what you're attempting can't
be done." -Terry Pratchett
--
http://mail.python.org/mailman/listinfo/python-list
Re: Style help for a Smalltalk-hack
On 2012-10-23 01:43, Travis Griggs wrote:
I'm writing some code that does a structured read from formatted binary file.
The code I came up with looks like:
# get the first four bytes, the first gap field
chunk = byteStream.read(4)
while chunk:
# interpret the gap bytes
gap, = struct.unpack('>I', chunk)
# suck off the valveCount
valveCount, = struct.unpack('>I', byteStream.read(4))
# collect the next valveCount signatures
signatures = [struct.unpack('>I', byteStream.read(4))[0] for _ in
range(valveCount)]
self.script.append(ScriptSpan(gap=gap, valveSet=signatures))
# now get the next 4 bytes for the gap of the next iteration, it'll be
empty if we're at end
chunk = byteStream.read(4)
I can't help but thinking that there's some better way (i.e. more pythonic) to
do this that doesn't involve having to use another module (Construct) or
exploring generators or something like that. What bugs me about it is that
there is two different styles for reading/decoding values from the byte stream.
valveCount and signatures are both paired invocations of unpack() and read().
But to detect the end of the stream (file), I have to split the read() and
unpack() of the gap value across 3 different lines of the code, and they don't
even sit adjacent to each other.
I'm wandering up the Python curve with a passel of Smalltalk experience under
my belt, so I expect I'm struggling with trying to map something like this
across to python
[byteStream atEnd] whileFalse: [
gap := (byteStream next: 4) asInteger.
valveCount := (byteStream next: 4) asInteger.
signatures := (1 to: valveCount) collect: [:_ | (byteStream next: 4)
asInteger].
self script add: (ScriptSpan gap: gap valveSet: signatures).
]
The part that doesn't seem to be there in the standard python library is the
idea of an atEnd message for streams, it's inferred as a byproduct of a read().
Please be gentle/kind. I'm still learning. :) TIA
Another way you could do it is:
while True:
chunk = byteStream.read(4)
if not chunk:
break
...
And you could fetch multiple signatures in one read:
signatures = list(struct.unpack('>{}I'.format(valveCount),
byteStream.read(4 * valueCount)))
By the way, in Python the recommended style for variable names (well,
what you'd call a 'variable' in other languages :-)) is lowercase with
underscores, e.g. "byte_stream".
--
http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
On Oct 22, 9:19 pm, rusi wrote: > On 10/21/2012 11:33 AM, Vincent Davis wrote: > > > I am looking for a good way to get every pair from a string. For example, > > input: > > x = 'apple' > > output > > 'ap' > > 'pp' > > 'pl' > > 'le' > > Maybe zip before izip for a noob? > > >>> s="apple" > >>> [a+b for a,b in zip(s, s[1:])] > > ['ap', 'pp', 'pl', 'le'] Daniel wrote: > This is a little bit faster: > > s = "apple" > [s[i:i+2] for i in range(len(s)-1)] Nice! I always find pairs of structural decomposition of input vs recomposition of output interesting. In this case the use of slices: to decompose: s -> s[1:] vs doing s[i:i+2] -- http://mail.python.org/mailman/listinfo/python-list
Re: get each pair from a string.
Le mardi 23 octobre 2012 06:59:49 UTC+2, rusi a écrit : > On Oct 22, 9:19 pm, rusi wrote: > > > On 10/21/2012 11:33 AM, Vincent Davis wrote: > > > > > > > I am looking for a good way to get every pair from a string. For example, > > > > input: > > > > x = 'apple' > > > > output > > > > 'ap' > > > > 'pp' > > > > 'pl' > > > > 'le' > > > > > > Maybe zip before izip for a noob? > > > > > > >>> s="apple" > > > >>> [a+b for a,b in zip(s, s[1:])] > > > > > > ['ap', 'pp', 'pl', 'le'] > > > > Daniel wrote: > > > This is a little bit faster: > > > > > > s = "apple" > > > [s[i:i+2] for i in range(len(s)-1)] > > > > Nice! I always find pairs of structural decomposition of input vs > > recomposition of output interesting. > > In this case the use of slices: > > to decompose: s -> s[1:] > > vs doing s[i:i+2] Why bother with speeed? The latest Python version is systematically slower than the previous ones as soon as one uses non "ascii strings". Python users are discussing "code optimizations" without realizing the tool they are using, has killed itself its own performances. (Replace 'apple' with 'ap需') jmf -- http://mail.python.org/mailman/listinfo/python-list
