|
POST
|
This appears to be for an exercise, so does the solution only need to work for this one sentence, or does it need to be generally applicable to strings? If the former, than you can do something like: >>> s = "RYAN O'NEAL AND JERRY O'CONNELL WERE ON CONAN O'BRIEN."
>>> lower_list = ["and", "were", "on"]
>>> " ".join(
... i.lower() if i.lower() in lower_list else i.title()
... for i in s.split()
... )
"Ryan O'Neal and Jerry O'Connell were on Conan O'Brien."
>>>
... View more
04-13-2022
05:01 PM
|
1
|
1
|
4189
|
|
POST
|
What you are after is called true casing/truecasing, and it is a natural language processing problem. The Python built-in string type does not have any method for doing such handling of a string. There are quite a few Python packages that do truecasing, but you would have to install them and then write a fairly involved code block expression. I am with Dan, str.title() is probably the best compromise in terms of effort to results.
... View more
04-13-2022
02:10 PM
|
1
|
3
|
4211
|
|
POST
|
If someone's reply works for you, please accept it as a solution so others can tell there is a solution to the question when browsing questions.
... View more
03-09-2022
06:16 AM
|
0
|
0
|
2372
|
|
POST
|
Not all ArcPy functions that work with workspaces, e.g., ListFeatureClasses, work with the new "memory" workspace. ArcPy DA Walk usually does if you know the underlying name of the workspace and not its "memory" alias. Try: next(arcpy.da.Walk("InMemoryDB\GPProMemoryWorkspace"))
... View more
03-08-2022
03:09 PM
|
1
|
2
|
2420
|
|
POST
|
Similar, but slightly different, to another response using str.join() and string formatting: >>> word = "hello"
>>> print(f"_{'_'.join(word)}_")
_h_e_l_l_o_
>>>
... View more
03-06-2022
11:05 AM
|
0
|
1
|
2930
|
|
POST
|
If you feel/believe a reply answers your question, please mark it as the solution to let others know it answered the question for you.
... View more
02-22-2022
03:50 PM
|
0
|
0
|
2056
|
|
POST
|
@Bud, you posted this question on GIS StackExchange ( arcmap - Why does "for point in part:" work in a standalone ArcPy script, but not in the Field Calculator? - GIS Stack Exchange ) , and I just posted an answer there. I will put the answer here as well since I suspect a fair number of Esri Community members aren't users of GIS SE. The difference in behavior is due to the fact that objects within geoprocessing tools are not the same as objects within ArcPy. The pattern of directly iterating over items in a container, for point in part:, is a Python use pattern that is implemented in most ArcPy classes but not in ArcObjects classes being used by geoprocessing tools. Looking to Esri's A quick tour of ArcPy -- ArcMap | Documentation ArcPy provides access to geoprocessing tools as well as additional functions, classes, and modules that allow you to create simple or complex workflows. Broadly speaking, ArcPy is organized in tools, functions, classes, and modules. Technically speaking, geoprocessing tools are functions available from arcpy—that is, they are accessed like any other Python function. However, to avoid confusion, a distinction is always made between tool and nontool functions (such as utility functions like ListFeatureClasses()). The key is in the second paragraph, i.e., geoprocessing tools are functions available from ArcPy but are not native ArcPy functions. Field Calculator is an example of a geoprocessing tool available through ArcPy as opposed to an ArcPy function that supports Python use patterns. Typically with geoprocessing tools, users either pass basic Python data types (e.g., string) or ArcPy objects that are then converted to geoprocessing objects behind the scenes. Field Calculator is somewhat unique in that users can pass free-form Python code within a Python string for the tool to execute. In ArcPy, arcobjects are created from geoprocessing code and then extended to add support for core Python functionality and patterns. For ArcPy Array, that includes implementing the Python __iter__ special method that supports the pattern of directly iterating over items in a container. From 3. Data model — Python 3.10.2 documentation object.__iter__(self) This method is called when an iterator is required for a container. This method should return a new iterator object that can iterate over all the objects in the container. For mappings, it should iterate over the keys of the container. If you look at the ArrayMixin class within the mixins module, you can see the implementation of the __iter__ special method is similar to the Python code that currently works within Field Calculator. # represenative code since ArcPy modules are copyrighted
def __iter__(self):
for index in xrange(len(self)):
yield conversionObject(self.GetObject(index)) You can verify that a geoprocessing array does not implement the __iter__ special method while ArcPy Array does implement it: >>> import arcpy
>>>
>>> # Create geoprocessing array
>>> gp_arr = arcpy.gp.CreateObject("Array")
>>> type(gp_arr)
<type 'geoprocessing array object'>
>>>
>>> # Create ArcPy Array
>>> arcpy_arr = arcpy.Array()
>>> type(arcpy_arr)
<class 'arcpy.arcobjects.arcobjects.Array'>
>>>
>>> # Check the geoprocessing array for the __iter__ method
>>> gp_arr.__iter__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: Array: Get attribute __iter__ does not exist
>>>
>>> # Check the ArcPy Array for the __iter__ method
>>> arcpy_arr.__iter__
<bound method Array.__iter__ of <Array []>>
>>>
... View more
02-22-2022
02:35 PM
|
1
|
3
|
2067
|
|
POST
|
@Anonymous User, on an unrelated note, using "no" as an abbreviation for "number" in a field name isn't a good practice. For example your current field name is entertotalnocomplaints, which is intended to be read as "enter total number of compliants," but could be read as "enter total of no (or non) complaints." Also, the field does not appear to be entered by the user directly so it is a bit confusing to start it with "enter." I suggest a field name of "NumComplaints" or "ComplaintCount".
... View more
02-18-2022
09:11 AM
|
0
|
1
|
2153
|
|
POST
|
Use Walk—ArcGIS Pro | Documentation, much more Pythonic than the older List functions. The documentation has some working examples.
... View more
02-18-2022
07:17 AM
|
0
|
1
|
2804
|
|
IDEA
|
@KoryKramer, "searching" is just one form of making information available. I think what the OP is after is more than just searching, having the ability to browse too. The shortcoming with searching is that it depends on the people who logged the bug and the people searching for the defect to have the same terminology, which often times isn't the case.
... View more
02-10-2022
01:40 PM
|
0
|
0
|
14593
|
|
IDEA
|
As much as rewriting expressions into a new language can be a headache, or at least time consuming, I can't say I support Esri Development spending time on implementing this functionality when I believe there are so many other suggestions/ideas/functionality that will add more value to ArcGIS Pro than adding back VB support.. Python has much broader implementation and use than VB, both in and out of the geospatial realm, and Python has been supported in ArcGIS Desktop/ArcMap for more than a decade allowing plenty of time for transition.
... View more
02-09-2022
02:48 PM
|
0
|
0
|
4207
|
|
POST
|
If you want to select all records in a layer that are a multiple of a certain number, say 5, then you can use Select Layer By Attribute/Location and the SQL modulo operator: MOD(Field, 5) = 0 Note, the implementation of the modulo operator does vary between DBMS, so if MOD doesn't work you can search the internet for the specific modulo syntax for the backend data store you are using.
... View more
02-09-2022
02:40 PM
|
3
|
0
|
2359
|
|
IDEA
|
@KoryKramer, I know we have chatted about this before, but the subscription model implementation in Esri Support is weak, or should I say not robust. The organization I support has multiple versions of ArcGIS Desktop and multiple versions of ArcGIS Pro deployed, and subscribing to 6+ separate download channels sure feels like busy-work. Not to mention, I have to remember to subscribe to new products when they are released. The old RSS feeds ( RSS is not inherently insecure and is still used plenty) were great, simple and straightforward. Since hunting for Esri Support subscriptions doesn't make my priority list during the day, and the old RSS feeds are gone, I have resorted to downloading and parsing the patches.json file the patch notification tool uses. The file includes most products I help deploy and support; unfortunately, ArcGIS Pro patches aren't in it.
... View more
02-03-2022
08:33 AM
|
0
|
0
|
5228
|
|
POST
|
The error message tells you it isn't about common name, subject alternative names, or any other kind of name. The error is for a weak signature algorithm. You need to specify better settings for generating the cert.
... View more
01-28-2022
11:15 AM
|
0
|
0
|
3128
|
|
POST
|
@matu89, please mark some responses as accepted solution to close out this thread.
... View more
01-26-2022
07:15 AM
|
0
|
0
|
3496
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 2 | 07-06-2026 12:29 PM | |
| 1 | 07-06-2026 12:00 PM | |
| 2 | 06-05-2026 10:30 AM | |
| 1 | 05-29-2026 08:22 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|