|
Pylint say
W: 6: Using possibly undefined loop variable 'n'
with this code:
iterator = (i*i for i in range(100) if i % 3 == 0) for n, i in enumerate(iterator): do_something(i) print n
because if the iterator is empty (for example []) n is undefined, ok...
Started by wiso on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Have you considered merely initializing n to None before running the loop?
define a default value for "n" before the for statement? e.g n=None
iterator = (i*i for i in range(100) if i % 3 == 0) n=None for n, i in enumerate(iterator): do_something(i) ... .
|
|
First of all, using delete for anything allocated with new[] is undefined behaviour according to C++ standard.
In Visual C++ 7 such pairing can lead to one of the two consequences.
If the type new[]'ed has trivial constructor and destructor VC++ simply...
Started by sharptooth on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Struct A { char* ch; A(): ch( new char ){} ~A(){ delete ... .
If the non-trivial destructor that are not called for all but the first element in the array are supposed to free some memory you get a memory leak as these objects are not cleaned up properly .
|
|
Has anyone seen any how-to, documentation, or otherwise about how to load HTTP Modules dynamically for IIS?
Basically what I am trying to do is to load HTTP Modules, which I'll call HTTPModuleA, HTTPModuleB, and HTTPModuleC. The modules however could ...
Started by Adron on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Personally I built a similar system and used an article on CodeProject for guideance, but I can... .
You could look at the Microsoft Extensibility Framework to dynamically load modules, which I hear is great .
Unity is NOT a way to dynamically load modules.
|
Ask your Facebook Friends
|
What are some possibly unique development standards in your country? In general Information on the internet is focused around practices, standards and current programming tendencies in western countries, specifically the U.S.A.
However that tends to be...
Started by Robert Gould on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I'm not even sure if this differs much from what you do in the US but here goes:
At least here in Sweden companies tend to have a mix of English and Swedish versions of their OS so localization will come and bite you if you don't keep your eyes open about... .
|
|
Hi,
I'm having segfault problem in my application written using C++ and compiled using GCC 4.3.2. It is running under Debian 5 x64.
The process crashed on the following line of code:
#0 0x 7c720f in Action::LoadInfoFromDB (this=0x7fae10d38d90) at ../....
Started by O. Askari on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If m_tmap is a std::map it's ok - but did you verify slist[sId] is a valid subscript?
Or - you called a member function on a NULL (or... .
M_tmap[tId]->slist[sId] = pItem;
If that's the crash position, you're most likely indexing into non-existent data .
|
|
I need to convert a (possibly) null terminated array of ascii bytes to a string in C# and the fastest way I've found to do it is by using my UnsafeAsciiBytesToString method shown below. This method uses the String.String(sbyte*) constructor which contains...
Started by wizlb on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Probably along the lines of:
public static string UnsafeAsciiBytesToString(this byte[] buffer, int offset) { string result = null; ... .
Any reason not to use String(sbyte*, int, int)? That would avoid the issue of it potentially not being null-terminated .
|
|
I have a requirement to delay mail delivery through an SMTP Relay.
i.e.
Mail message is successfully recieved at time T. Forward Message to destination at time T+4hours.
Is this possible in sendmail or any other SMTP Relay.
Deployment platform is IBM ...
Started by Peauters on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The specifics of exactly how in your implementation are beyond... .
I believe you want to use an SMTP message queue to provide deferred delivery .
Check it out.
I'm not a network admin so I don't know the features, but we use PowerMTA and it does quite a bit .
|
|
I have some reporting services reports in 2005.
The use a shared data source in a rds file
Ideally I want them to use a connection string that is passed in from a configuration file, ideally via ASP.NETs ReportViewer control.
Is this possible?
Started by AJM on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Hi, you can do like this
DataSourceCredentials cred = new DataSourceCredentials(); cred.Name = 'credential_name'; cred.UserId = 'user_id'; cred.Password = 'password';
ReportViewer1.ServerReport.SetDataSourceCredential(new DataSourceCredentials[] { cred... .
|
|
I would like a particular set of Python subprocesses to be as low-impact as possible. I'm already using nice to help limit CPU consumption. But ideally I/O would be limited as well. (If skeptical, please humor me and assume there is value in doing this...
Started by Jacob Gabrielson on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Have fun :).
) # some error checking goes here, and possibly exception throwing
That's it, more or less.
|
|
I am trying to evaluate a function in a new context, ie, one that contains a certain word defined that does not exist in the scope. It is easy enough if I have the definition of the function as a string, but I would like to provide the ability to do this...
Started by kaleidomedallion on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
This will work, though I'm sure there's a lengthier, more elegant solution:
function foo() { } var bar = '' + foo; //type cast to a string by adding an empty string alert(bar);
The JS standard way is to call... .
Try simply taking out the .definition().
|