identifier

Refer to constant or package level variable instead of function level variable

孤街醉人 提交于 2019-11-29 16:54:19
package main import "fmt" const name = "Yosua" // or var name string = "James" func main() { name := "Jobs" fmt.Println(name) } How to refer to the constant and not the the function level variable? You can't. While the local variable name is in scope, the name name denotes the local variable. And there is no "qualifier" to refer to top-level identifiers. Spec: Declarations and scope: An identifier declared in a block may be redeclared in an inner block. While the identifier of the inner declaration is in scope, it denotes the entity declared by the inner declaration. If you need to access both

Best method to generate unique filenames when uploading files PHP [duplicate]

≡放荡痞女 提交于 2019-11-29 16:06:35
问题 This question already has an answer here: Unique and temporary file names in PHP? 9 answers Can any one suggest the best practice to generate unique file names for file uploads to avoid duplicate Entries? Thanks In Advance. 回答1: I usually either create a UID using uniqid() function for the filename or create a folder with the name of the username who is uploading the file and leave the original filename. The disadvantage of the first one is that you will have to save the original filename

Python underscore as a function parameter

試著忘記壹切 提交于 2019-11-29 06:37:26
问题 I have a python specific question. What does a single underscore _ as a parameter means? I have a function calling hexdump(_) . The _ was never defined, so I guess it has some special value, I could not find a reference telling me what it means on the net. I would be happy if you could tell me. 回答1: In Python shells, the underscore ( _ ) means the result of the last evaluated expression in the shell: >>> 2+3 5 >>> _ 5 There's also _2 , _3 and so on in IPython but not in the original Python

Unicode identifiers (function names) for non-localization purposes advisable?

。_饼干妹妹 提交于 2019-11-29 03:47:54
PHP allows Unicode identifiers for variables, functions, classes and constants anyhow. It was certainly intended for localized applications. Wether it's a good idea to code an API in anything but English is debatable, but it's undisputed that some development settings could demand it. $Schüssel = new Müsli(T_FRÜCHTE); But PHP allows more than just \p{L} for identifiers. You can use virtually any Unicode character, except those from the ASCII range (e.g. : is special or \ as that's already used as internal hack to support namespaces.) Anyway, you could do so, and I would even consider that a

Can't change bundle ID in project, greyed out

无人久伴 提交于 2019-11-29 02:06:34
问题 I'm having a problem with bundle identifiers. In the Summary section of my project in Xcode and under 'Identifiers', I can't seem to change the name of my bundle ID as it is greyed out. For example, my project name is 'My App'. In the identifier text box in Summary, it says this 'My-App' and is greyed out. However, my bundle id in my provisioning profile is this, 'com.mycompany.myapp'. I would like to change my bundle ID in my project to that but I can't seem to be able to. Any ideas why it

How to get a device identifier using Phonegap

岁酱吖の 提交于 2019-11-29 02:03:31
I need to get any number, serial, key or whatever to identify every device where my phonegap app is running, I think uuid also changes when the app updates so it wouldn't work for me. The scenario here is that the user can synchronize data from the app, so I need to know which device has synchronized and which has not, or if it needs to update new data that maybe others devices have already done, etc any ideas? <script type="text/javascript" charset="utf-8"> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var element = document.getElementById(

How to check if a string is a valid python identifier? including keyword check?

会有一股神秘感。 提交于 2019-11-29 02:00:33
问题 Does anyone know if there is any builtin python method that will check if something is a valid python variable name, INCLUDING a check against reserved keywords? (so, ie, something like 'in' or 'for' would fail...) Failing that, does anyone know of where I can get a list of reserved keywords (ie, dyanamically, from within python, as opposed to copy-and-pasting something from the online docs)? Or, have another good way of writing your own check? Surprisingly, testing by wrapping a setattr in

Which part of a GUID is most worth keeping?

大城市里の小女人 提交于 2019-11-29 01:31:10
I need to generate a unique ID and was considering Guid.NewGuid to do this, which generates something of the form: 0fe66778-c4a8-4f93-9bda-366224df6f11 This is a little long for the string-type database column that it will end up residing in, so I was planning on truncating it. The question is: Is one end of a GUID more preferable than the rest in terms of uniqueness? Should I be lopping off the start, the end, or removing parts from the middle? Or does it just not matter? You can save space by using a base64 string instead: var g = Guid.NewGuid(); var s = Convert.ToBase64String(g.ToByteArray(

Python globals, locals, and UnboundLocalError

丶灬走出姿态 提交于 2019-11-28 23:55:56
I ran across this case of UnboundLocalError recently, which seems strange: import pprint def main(): if 'pprint' in globals(): print 'pprint is in globals()' pprint.pprint('Spam') from pprint import pprint pprint('Eggs') if __name__ == '__main__': main() Which produces: pprint is in globals() Traceback (most recent call last): File "weird.py", line 9, in <module> if __name__ == '__main__': main() File "weird.py", line 5, in main pprint.pprint('Spam') UnboundLocalError: local variable 'pprint' referenced before assignment pprint is clearly bound in globals , and is going to be bound in locals

Remove first levels of identifier in array

杀马特。学长 韩版系。学妹 提交于 2019-11-28 23:52:54
I think this has been up before, but could'nt find any answer to it. If it's already answered please point me in the right direction with a link. I have an array that I wan't to remove the first levels of identifier. I think there is a function for this? Example of how it is: [0] => Array ( [8] => Röd ) [1] => Array ( [8] => Blå ) [2] => Array ( [6] => Bobo ) [3] => Array ( [8] => Grön ) [4] => Array ( [7] => Sten ) [5] => Array ( [8] => Vit ) [6] => Array ( [7] => Guld ) [7] => Array ( [6] => Lyxig ) What I wan't [8] => Röd [8] => Blå [6] => Bobo [8] => Grön [7] => Sten [8] => Vit [7] => Guld