Конвенция для имен файлов универсальных классов

Я думаю, что гораздо проще было бы прочитать его в pandas DataFrame напрямую, используя pd.read_html() , что немедленно вернет (длина 1) список всех таблиц из URL: [ 114]

url = r'http://www.espn.com/college-sports/basketball/recruiting/playerrankings/_/view/espnu100/sort/rank/class/2019'
dfs = pd.read_html(url, header=0)
dfs[0].head()
#   RK                                 PLAYER POS  \
#0   1     James WisemanVideo | Scouts Report   C   
#1   2      Cole AnthonyVideo | Scouts Report  PG   
#2   3  Vernon Carey Jr.Video | Scouts Report   C   
#3   4    Isaiah StewartVideo | Scouts Report   C   
#4   5   Anthony EdwardsVideo | Scouts Report  SG   
#
#                                     HOMETOWN      HT   WT  STARS  GRADE  \
#0                 Memphis, TNEast High School   7'0''  230    NaN     97   
#1               Briarwood, NYOak Hill Academy   6'3''  185    NaN     97   
#2  Southwest Ranches, FLNSU University School  6'10''  275    NaN     97   
#3              Rochester, NYLa Lumiere School   6'9''  245    NaN     97   
#4               Atlanta, GAHoly Spirit School   6'4''  205    NaN     97   
#
#                          SCHOOL  
#0                  MemphisSigned  
#1                           List  
#2        DukeCommitted12/06/2018  
#3  WashingtonCommitted01/20/2019  
#4     GeorgiaCommitted02/11/2019 

Конечно, вам придется сделать некоторую очистку, но я думаю, что это будет намного эффективнее, чем чтение всего в списки.

48
задан Waylon Flinn 29 April 2009 в 20:07
поделиться

7 ответов

В Microsoft,

35
ответ дан 26 November 2019 в 18:44
поделиться

All new Microsoft classes use generics. The Queue and ArrayList were there before generics came out. Generics is the way forward.

The convention for one-class-per-single file is to name the filename after the class name (whether generic of not). For MyClass, you'll have MyClas.cs. For every new namespace you'll need to create a new folder. This is how Visual Studio also works.

1
ответ дан 26 November 2019 в 18:44
поделиться

I would probably put them in folders and use the namespace mechanism instead. You can compare with System.Collections vs. System.Collections.Generic. On the other hand, if it's more common than not that the classes use generics, perhaps it's better to point out those that are not. That is if you really want to separate the generic classes from other classes. Personally I usually don't bother to do that, since I don't really see a practical benefit from it.

1
ответ дан 26 November 2019 в 18:44
поделиться

How about:

Type.cs

and

TypeGeneric.cs

Whenever I have done this in the past I have always put both types in one file with the non-generic type as the file name. I think that this makes things pretty clear as .NET has no conventions/restrictions on one type per file like Java does.

But if you must then I would suggest something like I have above, and using a suffix will make the files show up together in any alphabetized list (Solution Explorer, Windows Explorer, etc.).

Here is another idea:

Type`1.cs

This would allow you to break out different generic types by the number of generic type parameters they accepted. Its just a thought though as I still think it would be simpler to just put all the types in one file.

1
ответ дан 26 November 2019 в 18:44
поделиться

From the responses so far it seems there isn't a consensus.

Using the same filename in a sub-namespace (and sub-folder) "Generics" (like System.Collecctions.Generics) is an option. But it's not always desirable to create a new namespace.

For example, in an existing namespace with non-generic classes that are maintained for backwards compatibility, but marked with ObsoleteAttribute, it's probably better to keep the generic versions in the same namespace.

I think a suffix is a reasonable way to go. I've adopted a convention of using the type parameters as a suffix (so: MyClassT for MyClass, or MyDictionaryKV for MyDictionary.

1
ответ дан 26 November 2019 в 18:44
поделиться

I'd probably have two folders in the project, something like Gereric, NonGeneric or something like that. They can still be in the same namespace, and then they can both have the same file name. Just a thought...

0
ответ дан 26 November 2019 в 18:44
поделиться

Только что нашел этот вопрос после поиска какие соглашения используют другие люди для имен файлов общих классов.

В последнее время я использовал ClassName [T] .cs . Мне очень нравится это соглашение, и я думаю, что оно превосходит другие по следующим причинам:

  • Параметры типа бросаются в глаза немного больше, чем они делают с Соглашение Microsoft (например, ClassNameOfT.cs ).
  • Позволяет иметь несколько параметры типа без лишнего путаница: Словарь [TKey, TValue] .cs
  • Это не требует от вас создания каких-либо специальных папок или размещения ваших общих классов в специальном пространстве имен. Если у вас есть только несколько общих классов, выделенное для них специальное пространство имен просто непрактично.

Я позаимствовал это соглашение из общего синтаксиса Boo , хотя и немного изменен (Boo использует ] ClassName [of T] ).

Некоторые разработчики, похоже, боятся имен файлов, содержащих что угодно, кроме букв и подчеркиваний, но как только вы сможете пройти мимо этого соглашения, кажется, что это соглашение работает очень хорошо.

41
ответ дан 26 November 2019 в 18:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: